Find sum of numbers - C Program

C program to read two numbers and print sum of the numbers.

Solution:

In this program, we will learn how to read numbers from user. In C Language, for reading numbers from user scanf function is used.

The syntax of scanf is:

scanf("format specifiers", &val1, &val2,...);

Here, format specifier depends on the data type of a val1, val2 etc.
e.g. Val1 is int type then format specifier is %d.

#include<stdio.h>
int main()
{
      int num1,num2, sum;
      printf("Enter Two Numbers :\n");
      scanf("%d %d", &num1,&num2);
      sum=num1+num2; // sum of two numbers calculate here
      printf("Sum of %d & %d  =  %d",num1,num2,sum);
      return 0;
}


Output:

sum of two numbers