top of page
Search

Write a C Program to Add Two Integers using User input?



Write a C Program to Add Two Integers using User input?

#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);

sumOfTwoNumbers = firstNumber + secondNumber;

/* sum of two numbers in stored in variable sumOfTwoNumbers */

printf("%d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);

// Displays sum

return 0;

}


Output:

Enter two integers: 12 11

12 + 11 = 23




20 views

Comments


bottom of page