The person running this app needs to enter two numbers. Each number is read by the scanf() method and saved in num1 and num2. The variable sum is then used to store the sum of these numbers. Last, the sum is shown with the printf() method. This program teaches you simple math operations and how to deal with more than one input.

#include <stdio.h>

int main() {
    int num1, num2, sum;
    printf("Enter two numbers: ");  // Ask the user to enter two numbers
    scanf("%d %d", &num1, &num2);  // Read and store the two numbers
    sum = num1 + num2;  // Calculate the sum of the numbers
    printf("Sum: %d\n", sum);  // Display the sum
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights