How does C program to add two integers work?

add integers


Courtesy: Programiz.com

In this program, the user is asked to enter two integers. These two integers are stored in variables number1 and number2 respectively.

printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);

Then, these two numbers are added using the + operator, and the result is stored in the sum variable.

sum = number1 + number2;
Adding two integers in C programming
Add Two Numbers

Finally, the printf() function is used to display the sum of numbers.

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

Comments

Popular posts from this blog

C program to read and display book information using structure

Function prototype and definition

Actual and Formal Parameters