Monday, December 29, 2014

operator(2)

1:
#include <stdio.h>


int main()
{
float a,b,sum;
a=5;b=2;
sum=a/b;
printf("%.0f / %.0f=%.2f",a,b,sum);
return 0;
}


output: 2.50

2:
#include <stdio.h>
///***assignment operator:

int main()
{
int a=5,b=6;
a+=5;
a-=b;
printf("%d %d",a,b);
return 0;
}


output: 4 6

3:
#include <stdio.h>
///***increment operator:

int main()
{
int a,b;
a=5;
a++;
printf("%d\n",a);
++a;
printf("%d\n",a);
b=a++;
printf("%d %d\n",a,b);
b=++a;
printf("%d %d\n",a,b);
return 0;
}

output: 6
              7
              8 7
              9 9 

No comments:

Post a Comment