Hello. I am not very experienced with C so this may be a simple thing to fix, but I am writing a C program that converts an inputted temperature to either Fahrenheit or Centigrade. The program compiles, but when it runs, it simply converts the temp. only to Centigrade, never Fahrenheit. If anyone can see where my problem is I'd greatly appreciate it.
Here is the code that I have:
Code:#include <stdio.h> int c2f(int); int f2c(int); main() { int temp1=0; char x; while(temp1 != -99){ printf("Please input a temperature (-99 to exit):\n"); scanf("%d", &temp1); if(temp1 != -99){ printf("Would you like to convert to Centigrade or Fahrenheit (C or F)\n"); scanf("%1s", &x); if(x == 'c' || 'C') printf("The temperature in Centigrade is: %d\n\n", f2c(temp1)); else{ if(x == 'f' || 'F') printf("The temperature in Fahrenheit is: %d\n\n", c2f(temp1)); else printf("Invalid Input\n"); } } } } int f2c(int x) { int y; y=(x-32) * 5 / 9; return y; } int c2f(int x) { int y; y=(x*9/5) + 32; return y; }