Relational operators Relational operators work the same way but return different results >,>,<,<=,=,!= In Java, they return values Faise and true In C/C+t, they return values o and 1 In c/C++ a value of zero means false any value that is not zero means true Eg,1,5,-100000314159,6626068×10 21
21 Relational Operators • Relational operators work the same way but return different results:– >, >=, <, <=, ==, != • In Java, they return values FALSE and TRUE • In C/C++, they return values 0 and 1 • In C/C++, – a value of zero means false – any value that is not zero means true – E.g., 1, 5, -1000000, 3.14159, 6.626068 × 10-34
Conditional and bitwise Operators Conditional execution operators are same in Java and C/C++ s&,! · Bitwise operators are same in Java and C/O艹+: I,&,a for bit-by-bit operations with a word Shift operators differ a little bit < (left shift)is the same >(right shift) is machine dependent in C/C++ I.e. whether to fill from left with zeros or sign bits
22 Conditional and Bitwise Operators • Conditional execution operators are same in Java and C/C++:– ||, &&, ! • Bitwise operators are same in Java and C/C++:– |, &, ^ for bit-by-bit operations with a word • Shift operators differ a little bit << (left shift) is the same >> (right shift) is machine dependent in C/C++ • I.e., whether to fill from left with zeros or sign bits
Assignment and Unary Operators Assignment operators work the same The following unary operators are available C/C++ but not in java invert the bits of a word pointer creation pointer dereference sizeof of bytes in operand or data type - pointer dereference with field selection There is no pointer in Java
23 Assignment and Unary Operators • Assignment operators work the same:– =, +=, -=, *=, /=, &=, |=, ^= • The following unary operators are available C/C++ but not in Java ~ invert the bits of a word * pointer creation & pointer dereference sizeof # of bytes in operand or data type -> pointer dereference with field selection There is no pointer in Java
Formatted Input output very different between C and Java Very different between C and c++ handled by library functions in C printf () scanfo getco putc() Many others
24 Formatted Input & Output • Very different between C and Java • Very different between C and C++ • Handled by library functions in C • printf() • scanf() • getc() • putc() • Many others!
printf (-Print formatted data printf("string containing i specifiers", expr1, expr2/ expr3,)i Copy the string, character-by-character, to the output When the ith ib is encountered treat it as a conversion specifier for converting the value of expri Copy the converted value to the output per instructions encoded in the conversion specifier Return number of characters printed
25 printf() – Print formatted data printf("string containing '%' specifiers", expr1, expr2, expr3, …); • Copy the string, character-by-character, to the output. • When the ith '%' is encountered, treat it as a conversion specifier for converting the value of expri • Copy the converted value to the output per instructions encoded in the conversion specifier • Return number of characters printed