We read your photo as:
Write a C program to add two numbers and display the result.
Computer Science
ScanSolve AI Answer
Here is a C program to add two numbers and display the result.
#include <stdio.h> // Required for input/output functions like printf
int main() {
// Declare integer variables to store the two numbers and their sum
int number1 = 10;
int number2 = 25;
int sum;
// Calculate the sum of the two numbers
sum = number1 + number2;
// Display the numbers and their sum on the computer screen
printf("First number: %d\n", number1);
printf("Second number: %d\n", number2);
printf("Sum of the two numbers: %d\n", sum);
return 0; // Indicate successful program execution
}
Explanation:
- The
#include <stdio.h>line includes the standard input/output library, which provides functions likeprintffor displaying output. - The
mainfunction is the entry point of every C program. int number1 = 10;andint number2 = 25;declare two integer variables and initialize them with values.int sum;declares an integer variable to store the result.sum = number1 + number2;performs the addition.printf()statements are used to display the values ofnumber1,number2, andsumon the console. The%dis a format specifier for integers, and\ncreates a new line.return 0;indicates that the program executed successfully.
Output of the program:
First number: 10
Second number: 25
Sum of the two numbers: 35
Was this helpful?
Still stuck on this one?
Ask a follow-up, and the answer starts from this question.
Got a different question?Ask your own question
More Computer Science Questions
QWrite an algorithm and C code to calculate the sum and product of three integers entered by the…QWrite a C program that takes three integers, calculates their average and product, and prints the…QImplement an algorithm in Pascal or C that takes two integers, calculates their product, and…QFor number two use c programmingQWrite a C procedure to swap two integer values and demonstrate its usage.
Browse by topic:Programming