C program to demonstrate the use of all assignment operators.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("a = ");
scanf("%d",&a);
printf("b = ");
scanf("%d",&b);
c=a;
printf("after c=a a= %d and c= %d\n",a,c);
a+=b;
printf("after a+=b a=%d and b=%d\n",a,b);
a=c;
a-=b;
printf("after a-=b a=%d and b=%d\n",a,b);
a=c;
a*=b;
printf("after a*=b a=%d and b=%d\n",a,b);
a=c;
a/=b;
printf("after a/=b a=%d and b=%d\n",a,b);
a=c;
a%=b;
printf("after a%%=b a=%d and b=%d\n",a,b);
getch();
}
Output:
a = 5
b = 2
after c=a a= 5 and c= 5
after a+=b a=7 and b=2
after a-=b a=3 and b=2
after a*=b a=10 and b=2
after a/=b a=2 and b=2
after a%=b a=1 and b=2
👌🏻👌🏻👍🏻👍🏻
ReplyDelete