1:
operator-
///*** arithmatic operator
///***1.integer arithmatic= +,-,*,/,%
///***2.real arithmatic(float,double-forall)=(+,-,/,*)
2:
#include <stdio.h>
///***integer arithmatic.
int main()
{
int a,b,sum;
printf("please enter 1st number:",a);
scanf("%d",&a);
printf("please enter 2nd number:",b);
scanf("%d",&b);
sum= a+b;
printf("%d + %d =%d",a,b,sum);
return 0;
}
input: 5 2
output: 7
3:
#include <stdio.h>
///***integer arithmatic:(modulas)
int main()
{
int a,b,sum;
printf("please enter 1st integer:",a);
scanf("%d",&a);
printf("please enter 2nd integer:",b);
scanf("%d",&b);
sum= a%b;
printf("%d mod with %d=%d",a,b,sum);
return 0;
}
input: 5 2
output: 1
4:
#include <stdio.h>
int main ()
{
int a,b,c;
a=1;b=2;
printf("before interchange a=%d b=%d\n",a,b);
c=a;
a=b;
b=c;
printf("after interchange a=%d b=%d",a,b);
return 0;
}
output: a=2
b=1
No comments:
Post a Comment