Index « Previous Next »

Question

Write a program that prompts the user to enter two integers and display the total on the screen.

Source Code

#include <stdio.h>

int main()
{
    int num1, num2, sum;

    printf("Enter first number :");
    scanf("%d", &num1);

    printf("Enter second number :");
    scanf("%d", &num2);

    sum = num1 + num2;

    printf("sum of two numbers is %d", sum);

    return 0;
}

Output

Enter first number :15
Enter second number :22
sum of two numbers is 37