In C,C++ all relational &logical operators will return 0
or 1 as output When the expression is true then return value is 1 or else 0 Every non zero is true and zero is false Relational operators are <,>,<=,>=,==,!= a<b a is less than b a>b a is greater than b a<=b a is lesser than or equal to b a>=b a is greater than or equal to b a==b a is equal to b a!=b a is not equal to b Logical operators logical operators are &&,//,! && logical AND // logical OR let a,b are 2 statements & ! logical NOT 1 indicates true & 0 indicates false
a b a&&b a//b !a 1 1 1 1 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 Priority order to evaluate 1) ( ) 2) !,+,- sign of the value 3) *,/,% 4) +,- binary operation 5) >,<,>=,<= 6) ==,!= 7) && 8) // 9) ?,: 10) =
24) a=5>8 // 9<5; 0 // 0; 0 25) a=!5; 0 26) a=!0; 1 27)a=!5 !=5; 1 28) a=!(2>5); !0; 1 29)a=!(5>2) != 1 &&!(2<5)==0; !(1)!=1 &&!(1) ==0; 0!= 1 && 0 == 0; 1 && 1; 1 c programming is a case sensitive language i.e; uppercase & lowercase content is different In c programming language all existing keywords &predefined functions are available in lowercase only void main() { Printf(welcome); } o/p:- welcome
On TurboC 3.0 compiler by default standard input output and console input output functions are supported automatically thats why doesnt require to go for <stdio.h>,<conio.h> files but on high end compiler it is required Void is the key word which indicates the return type of the function Main is an identifier in the program which indicates startup point of an application { instruction block is started } closing brace instruction block is ended All the instructions must be placed with in the body
printf:- it is a predefined function, by using this we can print the data on console When we are working with the printf function , it can takes any no . of arguments but it must begin with double coats and remaining all arguments are seperated with coma (,) Begin the double coats what we pass it prints like that only but if any format specifiers are there then copies the data of that type Format specifiers:- Always format specifiers are one that decides that what type of data required to print on console %d int %f float %c char
token Smallest unit of programming or an individual unit of programming is called token A C programming is a combination of tokens Tokens can be keyword,operator,seperator,constant and any other identifier When we are working with the token but between the token we can pass any no . of spaces , tabs , and new line characters
examples printf(hello); hello printf(@hello#); @hello# printf(***welcome***); ***welcome*** printf(%d welcome %d 10,30); error function call missing (,) seperator should be used printf(%d welcome %d,10,30,); error function call missing (,) seperator should not be used printf(%d welcome %d,10,30); 10 welcome 30 printf(%d%d%d10,40,30); 104030 printf(%d %d %d,10,40,30); 10 40 30 printf(%d,%d,%d,10,40,30); 10,40,30
In printf statement begin the double coat whatever we pass everything is treated as normal characters only except format specifiers& special character printf(3+4=%d,3+4); 3+4=7 printf(%d*%d=%d,5,4,5*4); 5*4=20 printf(%d,%d,%d,10,30); 10,30,garbage/junk value In printf when we are passing an additional format specifier which doesnt having corresponding data then it brings some unknown or undefined value called garbage or junk value printf(%d %d,10,30,40); 10 30 In printf statement when we are passing an additional value which doesnt having corresponding format specifiers then that value need to be ignored if we require to print the data on screen we required to pass format specifier printf(total salary=%d,15,000); total salary=15 printf(total salary=%d,15000); total salary=15000 printf(total salary=%d); total salary=garbage value printf(%d %d,3>5,3<5); 0 1 printf(%d,3&&-3); 1 void main() { a=10; printf(a=%d,a); } Output:-error undefined symbol a Void main() { int a; a=10; printf(a=%d,a); } Output:-a=10