Answers for "addition of two numbers in c"

C
1

how to add two numbers in c

#include <stdio.h>
int main() {    
	int sum_tot = 0;
    int num_1, num_2;    
    printf("Please, Enter First integer: ");
    scanf("%d", &num_1);
    printf("\nNow Please, Enter Second integer: ");
    scanf("%d", &num_2);

    sum_tot = num_1 + num_2;      
    
    printf("\n%d + %d = %d", num_1, num_2, sum_tot);
    return 0;
}
Posted by: Guest on July-24-2021
0

addition in c

/*Program for adding two numbers*/
#include <stdio.h>
int main(){
	int a, b, sum; //declare the variables that will be used, a will store the first number, b second number and sum, the sum.
    printf("Enter the first number: \n"); //Prompts user to enter the first number.
    scanf("%d", &a);//Accepts input and saves it to variable a
    printf("Enter the second number: \n");
    scanf("%d", &b);
    sum = a + b; //Formular to add the two numbers.
    printf("Sum is %d", sum);
}
Posted by: Guest on April-17-2021

Code answers related to "addition of two numbers in c"

Code answers related to "C"

Browse Popular Code Answers by Language