Monday, 3 October 2011

03-10-2011 Working of Increament and Short Hand Operators


/*Just an example of usage of increment operators and short hand operators*/
#include<stdio.h>
#include<conio.h>
main()
{
      int a = 1, b = 1, c = 1, d = 1 ;
      printf("\n a prints: %d when a = 1",a);
      printf("\na++ prints: %d when a =1",a++);
      printf("\n++b prints: %d when b=1",++b);
      printf("\nwhen a = %d and b = %d then a+=b used inside printf prints: %d",a,b,(a+=b));
      c=a;
      d=b;
      b+=a;
      printf("\nwhen a = %d and b = %d then b+=a used before printf prints: %d",c,d,(b+=a));
      getche();
}

No comments:

Post a Comment