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

sum of two numbers in c


  1. #include <stdio.h>
  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

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu