In this article, I will tell you a C program for the addition of two integers entered by the user. It is a dynamic program which means you can take any value. Before you go to the program firstly you have to know some basics of C language which will help you to understand the program. Below are two basic videos on C (in Hindi) watch both of them then go through the program part.
Addition of two integer
- main() //main funcion
- printf(“enter two numbers”);
//stored two value
num3 = num1+num2;
- printf(“The sum is = %d”,
#include<stdio.h> this is the header file and this is our
int num1, num2, num3; here are three variables. In num1 and num2 we store our two integers values. In num3 we will store the sum of num1 and num2.
printf("enter two numbers"); this is a normal print statement that will print the message “enter two numbers”.
scanf("%d%d", &num1, &num2); here we have stored two integers on the address of num1 and num2.
num3 = num1+num2; the sum is stored in the num3 variable.
printf("The sum is = %d", num3); this statement will print the message “The sum is = (replace the value of num 3 with %d)”.