/* Converts Fahrenheit to Celsius */
#include <stdio.h> /* printf, scanf definitions */
void main()
{
double fahrenheit; //input
double celsius; //output
/*Get the temperature in degrees fahrenheit*/
printf("Please enter the temperature in degrees fahrenheit:");
scanf("%lf", &fahrenheit);
/*Convert the temperature in degrees fahrenheit to degrees celcius*/
celsius = (5.0 / 9.0) * (fahrenheit - 32.0);
/*Display the temperature in degrees celsius*/
printf("The temperature in celsius is %.2lf degrees.\n", celsius);
}
/*Converts Weight in Kilograms to Pounds*/
#include <stdio.h> //for using printf and scanf
#define kgPerPound 2.204
void main()
{
double kilograms; //input
double pounds; //output
/*Get the weight in kilograms*/
printf("Please enter the weight in kilograms:");
scanf("%lf", &kilograms);
/*Convert the weight in kilograms to Pounds*/
pounds=kgPerPound*kilograms;
/*Display the weight in pounds*/
printf("That equals %.3lf pounds.", pounds);
}
/*Calculates Volume and Base Area of Cone*/
#include <stdio.h> /*for using printf and scanf*/
#define PI 3.14
void main()
{
double height; //input
double radius; //input
double volumeOfCone; //output
double areaOfBase; //output
/*Get the height of cone*/
printf("Please enter the height of cone:");
scanf("%lf", &height);
/*Get the radius of cone*/
printf("Please enter the radius of cone:");
scanf("%lf", &radius);
/*Calculate the base area of cone*/
areaOfBase=PI*radius*radius;
/*Calculate the volume of cone*/
volumeOfCone=(1.0/3.0)*areaOfBase*height;
/*Display the base area of cone*/
printf("The base area of the cone with radius %.2lf is %.2lf.\n", radius, areaOfBase);
/*Display the volume of cone*/
printf("The volume of the cone with radius %.2lf and height %.2lf is %.2lf.\n", radius, height, volumeOfCone);
}
Etiketler: C, CSE, programlama, programlama dili