Write a program in C to add two numbers

Write a program in C to add two numbers: We have given the solution here for a program in C language to perform an arithmetic operation to add two numbers entered by the user and print the sum of them on the screen.

#include
#include
void main()
{
    clrscr();
    int num1, num2, total;
    printf("Enter first number num1: ");
    scanf("%d",&num1);
    printf("Enter second number num2: ");
    scanf("%d",&num2);
    total=num1+num2;
    printf("Sum of the two number entered is : %d",total);
    getch();
}

Examples

Let the two numbers entered by user be num1=5 and num2=7. Their sum will be 5+7 = 12. Here, is the output window of c program to add two numbers after execution of above code.