Problem Statement: Write a C program to find the sum of two numbers input by the user.
Description:
This program demonstrates how to take input from the user using scanf()
, perform basic arithmetic operations (addition in this case), and display the result using printf()
. It helps beginners understand variables and arithmetic in C.
Usage:
The user enters two integers, and the program computes and displays their sum.
Code:
C
#include <stdio.h>
int main() {
float celsius, fahrenheit;
// Asking user to input temperature in Celsius
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
// Converting to Fahrenheit
fahrenheit = (celsius * 9 / 5) + 32;
printf("%.2f Celsius = %.2f Fahrenheit\n", celsius, fahrenheit);
return 0;
}
Explanation:
scanf()
reads two integers from the user.- The sum is calculated using
num1 + num2
. printf()
prints the result.
Test here: