addition of two numbers in c

Solutions on MaxInterview for addition of two numbers in c by the best coders in the world

showing results for - "addition of two numbers in c"
Mario
29 Aug 2018
1#include <stdio.h>
2int main() {    
3
4    int number1, number2, sum;
5    
6    printf("Enter two integers: ");
7    scanf("%d %d", &number1, &number2);
8
9    // calculating sum
10    sum = number1 + number2;      
11    
12    printf("%d + %d = %d", number1, number2, sum);
13    return 0;
14}
15
Samuel
18 Jan 2018
1#include <stdio.h>
2int main() {    
3	int sum_tot = 0;
4    int num_1, num_2;    
5    printf("Please, Enter First integer: ");
6    scanf("%d", &num_1);
7    printf("\nNow Please, Enter Second integer: ");
8    scanf("%d", &num_2);
9
10    sum_tot = num_1 + num_2;      
11    
12    printf("\n%d + %d = %d", num_1, num_2, sum_tot);
13    return 0;
14}
Alessio
15 Jul 2016
1int num1,num2;
2printf("%d",num1+num2);
Ainsley
24 Oct 2016
1/*Program for adding two numbers*/
2#include <stdio.h>
3int main(){
4	int a, b, sum; //declare the variables that will be used, a will store the first number, b second number and sum, the sum.
5    printf("Enter the first number: \n"); //Prompts user to enter the first number.
6    scanf("%d", &a);//Accepts input and saves it to variable a
7    printf("Enter the second number: \n");
8    scanf("%d", &b);
9    sum = a + b; //Formular to add the two numbers.
10    printf("Sum is %d", sum);
11}