Computer Science, asked by mustribegum6, 2 days ago

write a basic program to input two numbers and print their sum​

Answers

Answered by leok76606
1

Answer:

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. Finally, the printf() function is used to display the sum of numbers.

Explanation:

Hope this will help you.

Answered by mahinderjeetkaur878
0

The program is written below:-

#include <stdio.h>

int main()

{

int number1, number2, sum;

printf("Enter two integers: ");

scanf("%d %d", &number1, &number2);

// calculating sum

sum = number1 + number2;

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

return 0;

}

Program Explanation

1. A function called scanf is available (predefined) in the C library to receive user input through the keyboard and store it in a variable.

2. The two input numbers are read here and stored in the variables num1 and num2.

3. Two integers are displayed with the format specifier "%d%d".

4. The C library has a function called printf that can be used to print the provided content in Monitor.

5. The values of the variables num1 and num2 are displayed here.

6. The values of num1 and num2 are printed in two lines by the Format Specifier "%dn%d".

To know more refer the links:-

https://brainly.in/question/27692611

https://brainly.in/question/27780461

#SPJ3

Similar questions