Email Id: 24MC3035@rgipt.ac.in
Branch: MATHEMATICS AND COMPUTING
Name: PRASHANT RANJAN
Roll No: 24MC3035
/*
1. WAP to perform the addition of two integers and display the result. Input must be given by user.
*/
#include<stdio.h>
int main() {
int num1, num2, sum;
// Ask user for input
printf("Enter 1st number: ");
scanf("%d", &num1);
printf("Enter 2nd number: ");
scanf("%d", &num2);
// Perform addition
sum = num1 + num2;
// Display result
printf("Sum is %d\n", sum);
getch();
return 0;
}
Output:
Enter 1st number: 25
Enter 2nd number: 75
Sum is 100
/*
2. WAP to find Fahrenheit for a given centigrade temperature.
*/
int main() {
float centigrade, fahrenheit;
// Ask user for input
printf("Enter the temperature in Centigrade: ");
scanf("%f", ¢igrade);
// Convert Centigrade to Fahrenheit
fahrenheit = (centigrade * 9 / 5) + 32;
// Display result
printf("The Fahrenheit temperature is: %.2f\n", fahrenheit);
getch();
return 0;
}
Keep reading with a 7-day free trial
Subscribe to MrRogueKnight’s Substack to keep reading this post and get 7 days of free access to the full post archives.