So my first time using functions and still dont think I've grasped them.
Program is to convert Fahrenheit to Celsius and vice verses. Using a switch for the menu to find out what you want to do, but each time you enter either option the program quits.
Code:
#include <stdio.h>
#include <stdlib.h>
void menu(){
printf("1. To convert from Fahrenheit to Celsius enter 1\n");
printf("2. To convert from Celsius to Fahrenheit enter 2\n");
printf("3. Quit\n");
printf("What would you like to do?\n");
printf("\n");
}
void celsiusToFahrenheit(){
int F=0, C=0;
printf("Enter a value you'd like to convert\n");
scanf("%d", &C);
F = 32 + C*1.8;
return C;
}
void fahrenheitToCelsius(){
int F=0, C=0;
printf("Enter a value you'd like to convert\n");
scanf("%d", &F);
C = (5/9)*(F-32);
return C;
}
int main(){
int choice=0;
menu();
scanf("%d", &choice);
switch(choice){
case '1': fahrenheitToCelsius();
break;
case '2': celsiusToFahrenheit();
break;
case '3': return 0;
}
}