A program to explain shorthand operators
C Programming Language 011
The following code shows how to write a program to explain shorthand operators
Program
#include <stdio.h>
void main()
{
int a = 2;
printf("a = %d\n", a);
a += 1;
printf("After a += 1, \t a is %d\n", a);
a -= 1;
printf("After a -= 1, \t a is %d\n", a);
a *= 2;
printf("After a *= 2, \t a is %d\n", a);
a /= 3;
printf("After a /= 3, \t a is %d\n", a);
printf("\n");
}
Result
a = 2
After a += 1, a is 3
After a -= 1, a is 2
After a *= 2, a is 4
After a /= 3, a is 1
Last Updated on
Comments