0% found this document useful (0 votes)
7 views3 pages

Assignment Comprog

The document is a C program that provides a menu for various calculations including metric unit conversion, area of a circle, force calculation, and temperature conversion. Users can select an option and input values to receive the corresponding results. If an invalid option is selected, the program prompts the user to choose a valid option.

Uploaded by

Rhon Jacob Ramos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Assignment Comprog

The document is a C program that provides a menu for various calculations including metric unit conversion, area of a circle, force calculation, and temperature conversion. Users can select an option and input values to receive the corresponding results. If an invalid option is selected, the program prompts the user to choose a valid option.

Uploaded by

Rhon Jacob Ramos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <stdio.

h>

int main() {
int choice;

printf("Select a calculation:\n");
printf("1. Convert Metric Units (Meters to Centimeters and Kilometers)\n");
printf("2. Calculate Area of a Circle\n");
printf("3. Calculate Force (Physics)\n");
printf("4. Convert Temperature (Celsius to Kelvin and Fahrenheit)\n");
printf("5. Convert Fahrenheit to Celsius\n");
scanf("%d", &choice);

if (choice == 1) {
float meters, centimeters, kilometers;

printf("Enter length in meters: ");


scanf("%f", &meters);

centimeters = meters * 100; // 1 meter = 100 centimeters


kilometers = meters / 1000; // 1 meter = 0.001 kilometers

printf("In centimeters: %.2f cm\n", centimeters);


printf("In kilometers: %.4f km\n", kilometers);
}
else if (choice == 2) {
float radius, area;

printf("Enter the radius of the circle: ");


scanf("%f", &radius);
area = 3.14159 * radius * radius; // Pi * r^2
printf("The area of the circle is: %.2f square units\n", area);
}
else if (choice == 3) {
float mass, acceleration, force;

printf("Enter mass (kg): ");


scanf("%f", &mass);
printf("Enter acceleration (m/s^2): ");
scanf("%f", &acceleration);

force = mass * acceleration;


printf("The Force is: %.2f N\n", force);
}
else if (choice == 4) {
float celsius, kelvin, fahrenheit;

printf("Enter temperature in Celsius: ");


scanf("%f", &celsius);

kelvin = celsius + 273.15;


fahrenheit = (celsius * 9 / 5) + 32;

printf("In Kelvin: %.2f K\n", kelvin);


printf("In Fahrenheit: %.2f F\n", fahrenheit);
}
else if (choice == 5) {
float fahrenheit, celsius;
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);

celsius = (fahrenheit - 32) * 5 / 9;

printf("In Celsius: %.2f C\n", celsius);


}
else {
printf("Invalid choice. Please select a valid option.\n");
}

return 0;
}

You might also like