Home » C Programs » Sum of Two Numbers in C Program

Sum of Two Numbers in C Program

Basic program to execute the sum of two numbers in c program. The user is requested to enter two integers in this example. The sum of these two integers is then computed and shown on the screen. You should be familiar with the following c programming subjects, such as basic c programs, in order to comprehend this example.

In this application, Printf() displays the text Hello World on the screen. The user is requested to enter two integers in this software. Variables a and b are used to store these two integers.

Then, using the + operator, these two values are added, and the result is saved in the sum variable. This program can be called as sum of two numbers in c program  or addition of two numbers in c.

Operator in C

A symbol that directs the compiler to execute particular mathematical or logical operations is known as an operator. The C programming language has a large number of built-in operators, including the following:

Arithmetic Operators It contains addition, subtraction, multiplication, division, modulus operations, increment, and decrement, as well as other fundamental arithmetic operations.

Mathematical computations are carried out using arithmetic operators. The assignment operators are used to give a property or variable a value. Numeric, date, system, time, and text can all be used as assignment operators. To accomplish comparisons, comparison operators are employed.

Sum of Two Numbers in C Program

``````//Sum of Two Numbers in C Program
#include <stdio.h>
int main()
{
int a, b, sum;
printf("Enter two integers");
scanf("%d %d", &a, &b);
sum = a + b;
printf("%d + %d = %d", a, b, sum);
return 0;
}``````

Output:

Enter two integers 45
45
45 + 45 = 90