C Programming Tutorial

Advertisements

Write a program to display sum of two numbers in C



       #include <stdio.h>
       #include <conio.h>
       void main()
       {

              int n1,n2,sum;
              clrscr();
              
              printf("\nEnter 1st number : "); 
              scanf("%d",&n1);

              printf("\nEnter 2nd number : "); 
              scanf("%d",&n2);
              
              sum = n1 + n2;
              
              printf("\nThe sum of %d and %d is %d",n1,n2,sum);

       }
       
   Output : 

              Enter 1st number : 78
              Enter 2nd number : 45
              The sum of 78 and 45 is 123




Advertisement