Assignment Operators in C

The assignment operators are used to perform assignment operation i.e. assigning some values to variables.

Here is a C program to demonstrate the assignment operators 

/**
* To demonstrate the assignment operators
*/
#include<stdio.h>
int main ( int argc, char **argv )
{
int x = 10;
int y = 12;
int res = 0;
/* x += y is same as x = x + y */
printf ( " x += y : %d \n", x += y );
x = 10;
y = 12;
/* x -= y is same as x = x - y */
printf ( " x -= y : %d \n", x -= y );
x = 10;
y = 12;
/* x *= y is same as x = x * y */
printf ( " x *= y : %d \n", x *= y );
x = 10;
y = 12;
/* x /= y is same as x = x / y */
printf ( " x /= y : %d \n", x /= y );
/* x %= y is same as x = x % y */
printf ( " x %%= y : %d \n", x %= y );
return 0;
}

Hope, it would be useful !!

If you like Advance Computing and would like to contribute, you can  mail your article to “computingadvance@gmail.com”. You will get credit as your name , email id, designation with article on this blog.

Leave a Reply