You are on page 1of 3

#include <stdio.

h>
double calculateC2F(double);
double calculateF2C(double);
double calculate1(double, double);
double calculate2(double, double);
void displayChart1(double, double);
void displayChart2(double, double);

int main(void)
{
int selection;
int i=0;
int choose;
double celsius;
double fahrenheit;
double celsius1;
double celsius2;
double fahrenheit1;
double fahrenheit2;
double fahrenheitC;
double celsiusF;
float sumF;
float sumC;

printf("Welcome to Temperature Converter\n");

while (i >= 0)
{
printf("How May I Help You?\n");
printf("1. Convert Celsius to Fahrenheit\n ");
printf("2. Convert Fahrenheit to Celsius\n ");
printf("3. Print Converter Table\n ");
printf("4. End\n ");
printf("Selesction : ");
scanf_s("%d", &selection);

if (selection = 1)
{
float sumF;

printf("\nPlease enter value in Celsius : ");


scanf_s("%f", &celsius);
sumF = calculateC2F (celsius);
printf("\n%.2f degree Celsius is equivalent to %.2f degree
Fahrenheit", celsius, sumF);

else if (selection = 2)
{
float sumC;

printf("\nPlease enter value in Fahrenheit : ");


scanf_s("%f", &fahrenheit);
sumC = calculateF2C (fahrenheit);
printf("\n%.2f degree Fahrenheit is equivalent to %.2f degree
Celsius", fahrenheit, sumC);
}
else if (selection = 3)
{
printf("\nPlease choose 1. Celsius or 2. Fahrenheit : ");
scanf_s("%d", &choose);

if (choose = 1)
{
printf("\nEnter your starting value in Celsius : ");
scanf_s("%f", &celsius1);
printf("\nEnter your end value in Celsius : ");
scanf_s("%f", &celsius2);
printf("\n");
fahrenheitC = calculate1(celsius1, celsius2);
displayChart1(celsius1, fahrenheitC);
}

if (choose = 2)
{

printf("\nEnter your starting value in Fahrenheit : ");


scanf_s("%f", &fahrenheit1);
printf("\nEnter your end value in Fahrenheit : ");
scanf_s("%f", &fahrenheit2);
printf("\n");
fahrenheitC = calculate2(fahrenheit1, fahrenheit2);
displayChart2(fahrenheit1, celsiusF);
}
}

else
{
return 0;
}

double calculateC2F(double c1)


{
float sumF;
sumF = (9 / 5)(c1) + 32;
return sumF;
}

double calculateF2C(double f1)


{
float sumC;
sumC = ((f1 - 32)(5)) / 9);
return sumC;
}

double calculate1(double num1, double num2)


{
double ii;
double fahrenheitC;

for (ii = num1; ii <= num2; ii++)


fahrenheitC = (9 / 5)(num1) + 32;
return fahrenheitC;
}

double calculate2(double num1, double num2)


{
double ii;
double celsiusF;

for (ii = num1; ii <= num2; ii++)


celsiusF = (9 / 5)(num1) + 32;
return celsiusF;
}

void displayChart1(double fahrenheitC, double num1)


{
printf("\nPrinting Chart... ");
printf("\nCelsius Fahrenheit");
printf("\n%.2f %.2f", num1, fahrenheitC);
}

void displayChart2(double celsiusF, double num1)


{
printf("\nPrinting Chart... ");
printf("\nFahrenheit Celsius");
printf("\n%.2f %.2f", num1, celsiusF);
}
}

You might also like