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


Related Topic: Do-while Loop Explained with Syntax and Examples of C programming


#Interview #Preperation #Placement #OffCampusing #Engineering #OnCampus #PrivateJobPreperation #JobPreperation#CodingPreperation #AMCAT #Automata #JobsforGraduates #HighestPayingJobsforGraduates

#coding #codinglife #codingisfun #codingproblems #CoffeeWithCodes #CWC #Cprogramming #cprogramminglanguage #competitiveprogramming