write a program to add two numbers

Below is the program to add two numbers with explanation.

#include <stdio.h>

int main() {    

    int number1, number2, sum;

    printf(“Enter two integers: “);

    scanf(“%d %d”, &number1, &number2);

    // calculate the sum

    sum = number1 + number2;      

    printf(“%d + %d = %d”, number1, number2, sum);

    return 0;

}

Output-

Enter two integers: 5 8

5 + 8 = 13

If you want learn C programming, then join our course.

Leave a Reply

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