C program to add two numbers

>C program to add two numbers:-

#include<stdio.h>
 
int main()
{
   int a, b, c;
 
   printf("Enter two numbers to add\n");
   scanf("%d%d",&a,&b);
 
   c = a + b;
 
   printf("Sum of entered numbers = %d\n",c);
 
   return 0;
}
 
 
Output of program: 
 

>Addition without using third variable:-

 

#include<stdio.h>
 
main()
{
   int a = 1, b = 2;
 
  
   a = a + b;
 
  
   printf("addition  of a and b = %d\n", a);
 
   return 0;
}
 
output of program: 

 

 

 

Comments

Popular posts from this blog

C Program to Display the ATM Transaction

Fortran

Java programming language