I am a newbie when it come to C++ but I think I am close to solving this code. Can anyone tell me where my mistake is. I am having on the Temperature reading.
Code:#include<stdio.h> iint choice; /* 1 to convert celsius, 2 to convert fahrenheit. // int c; // degrees in celsius// int f; // degrees in fahrenheit// float ctemp, ftemp; //temperatures// int main ( void ) { printf( "This program converts from celsius to fahrenheit and fahrenheit to celsius.\n" ); printf( "Enter 1 for Fahrenheit to Celsius or 2 for Celsius to Farenheit.\n" ); scanf("%d", &choice); //input from user// if (choice == 1) { printf( "Enter degrees in Fahrenheit."); scanf ("%d", &f); ctemp = (5/9) * (f-32); printf ( "Temperature in Celsius is", ctemp); //Degrees in celsius// } else{ if (choice == 2) { printf( "Enter degrees in Celsius."); scanf ("%d", &c); //get degrees celsius from user// ftemp = (9/5) * (c+32); printf ( "Temperature in farenheit is", ftemp); //output degrees in celsius// } else printf ( "Bad selection." ); } return 0; //end program// }



LinkBack URL
About LinkBacks



