Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

#include <stdio.

h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int select;
do{
FILE *f;
float X, Y, Pi;
Pi = 3.14;
f = fopen("Calculations.txt","a");
printf("Please chose a file to open\n");
printf("1.Area of Square\n 2.Area of a Circle\n 3.Fahrenheit to Celsius\n 4.Celsius to
Fahrenheit\n 5.EXIT\n");
scanf("%i",&select);
if (select == 1)
{
printf("Please enter two numbers to Multiply\n");
scanf("%f", &X);
scanf("%f", &Y);
fprintf(f,"The Area of Rectangle:%f\n\n", X * Y);
printf("Written to File named Calculations\n");
fclose(f);
}
if (select == 2)
{
printf("Please enter you Radius\n");
scanf("%f", &X);

fprintf(f,"The Area of Circle:%.2f\n\n", Pi * (X * X));


printf("Written to File named Calculations\n");
fclose(f);
}

if (select == 3)
{
printf("Please enter you Farenheit Degree\n");
scanf("%f", &X);
fprintf(f,"Celsius Degree:%f\n\n", (X - 32) * 5 / 9);
fclose(f);
}

if (select == 4)
{
printf("Please enter you Celsius Degree\n");
scanf("%f", &X);
fprintf(f,"Fahrenheit Degree:%f\n\n", ((X * 9) / 5) + 32);
fclose(f);
}

}while (select !=5);


system("PAUSE");

return 0;
}

You might also like