Beruflich Dokumente
Kultur Dokumente
modulus operator (%) cannot be applied on a float. On using % the sign of the re
mainder is always same as the sign of the numerator. Thus 5 % 2 yields 1, whereas,
5 % -2 yields 1.
char a, b, d ;
a = 'F' ;
b = 'G' ;
d = '+' ;
When we do this the ASCII values of the characters are stored in the variables.
ASCII values are used to represent any character in memory. The ASCII values of F
and G are 70 and 71.
For b = 3 ^ 2 ;
#include <math.h>
main( )
{
int a ;
a = pow ( 3, 2 ) ;
printf ( %d , a ) ;
}
int x, y ;
scanf ( "%d", &x ) ;
y = ( x > 5 ? 3 : 4 ) ;
This statement will store 3 in y if x is greater than 5,
otherwise it will store 4 in y.
main( )
{
int i = 1 ;
while (i <= 10 )
{
printf ("%d\n", i ) ;
i+= 1 ;
}
}
main( )
{
int i = 1 ;
for ( ; i <= 10 ; )
{
printf ( "%d\n", i ) ;
i = i + 1 ;
}
}
Here, neither the initialisation, nor the incrementation is done in the for sta
tement, but still the two semicolons are necessary.
main( )
{
int i ;
for ( i = 0 ; i++ < 10 ; )
printf ( "%d\n", i ) ;
}
Here, the comparison as well as the incrementation is done through the same stat
ement, i++ < 10. Since the ++ operator comes after i firstly comparison is don
e, followed by incrementation. Note that it is necessary to initialize i to 0
main( )
{
int i ;
for ( i = 0 ; ++i <= 10 ; )
printf ( "%d\n", i ) ;
}
Here, both, the comparison and the incrementation is done through the same state
ment, ++i <= 10. Since ++ precedes i firstly incrementation is done, followed b
y comparison. Note that it is necessary to initialize i to 0.
{
m = r + c ;
printf ( "r = %d c = %d sum = %d\n", r, c, sum ) ;
}
Instead of using two statements, one to calculate sum and another to print it ou
t, we can compact this into one single statement by saying:
printf ( "r = %d c = %d sum = %d\n", r, c, r + c ) ;