;

C Program to Print the Sum of Two Integers


Tutorialsrack 03/11/2019 C

In this C program, we will learn how to write a program to print the sum of Two Integers. In this program, we are displaying the message using printf function and read the input taken from the user using scanf function.

Here is the code of the program to print the sum of Two Integers

Code - C Program to Print the Sum of Two Integers
/*C Program to Print Sum of Two Integers*/
#include <stdio.h>
int main()
{
    int firstNumber, secondNumber, sumOfTwoNumbers;

    printf("Enter two integers: ");
    // Two integers entered by user is stored using scanf() function
    scanf("%d %d", &firstNumber, &secondNumber);
    // sum of two numbers in stored in variable sumOfTwoNumbers
    sumOfTwoNumbers = firstNumber + secondNumber;
    // Displays sum
    printf("Sum of Two Integer is: %d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);
    return 0;
}
Output

Enter two integers: 102
52
Sum of Two Integer is: 102 + 52 = 154
--------------------------------
Process exited after 7.975 seconds with return value 0
Press any key to continue . . .


Related Posts



Comments

Recent Posts
Tags