Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C Program to find sum of two numbers

 Lets discuss a basic c program

  • Sum of two integers using c. This might be the first practice program for all users.
  • To check sum of two integers , read input from user and store in two corresponding integer variables.
  • Also take one more variable to store result of sum of two numbers
  • c= a+b
  • Print result using printf


  1. #include
  2. // program to check sum of two numbers in c
  3. // write a c program to find sum of two integers
  4. // www.instanceofjava.com
  5. int main()
  6. {
  7.     int x, y, sum;
  8.     // read input from user
  9.     printf(" Please enter any two numbers: ");
  10.     scanf("%d %d", &x, &y);
  11.     // sum of two numbers
  12.     sum=x+y;
  13.     
  14.     printf("Sum of %d and %d is %d", x, y, sum);

  15.     getch();
  16. }
Output:

  1. Please enter any two numbers
  2. 10
  3. 20
  4. Sum of 10 and 20 is 30


This post first appeared on Java Tutorial - InstanceOfJava, please read the originial post: here

Share the post

C Program to find sum of two numbers

×

Subscribe to Java Tutorial - Instanceofjava

Get updates delivered right to your inbox!

Thank you for your subscription

×