Sunday, August 15, 2021

Sum of two numbers using increment & decrement in c

Write a program to print sum of two number using increment Operator

 #include<stdio.h>

int main()
{
int a,b,c;
printf("Enter the two number ");
scanf("%d %d",&a, &b);
c=a+b;
printf("\n Sum of two number = %d ",c);
c++; //Increment operator
printf("\n Increment of two number = %d ",c);
return 0;
}
OUTPUT
Enter the two number 8
5
 Sum of two number = 13
 Increment of two number = 14  
 
 

Write a program to print sum of two numbers using Decrement

#include<stdio.h>

int main()
{
int a,b,c;

printf("Enter the two number ");
scanf("%d %d",&a, &b);
c=a+b;
printf("\n sum of two number = %d ",c);
c--; //Decrement operator
printf("\n Decrement of two number = %d ",c);
return 0;

OUTPUT 

Enter the two number 8
4
sum of two number = 12
 Decrement of two number = 11 

No comments:

Post a Comment