Hi, brand new to programming and the site so far seems to have helped a lot. Just started today and finished my first little program, which converts celsius and fahrenheit. It seems like I can learn the basic stuff to get started from this website but after that I was looking at getting a book, which one would you guys recommend?
If you have any tips please help me.
Code:
#include <stdio.h>
int main()
{
int y;
printf("--------------------------------\n"
"Temperture Converter\n"
"--------------------------------\n");
while(1) {
printf("1:)Fahrenheit to celsius\n");
printf("2:)Celsius to fahrenheit \n");
scanf("%d", &y);
if(y==1 || y==2){
break;
}
else {
printf("\n%d is not 1 or 2, please try again\n", y);
continue;
}
}
if (y == 1) {
int uent, sol;
float frac;
frac = .555555556;
printf("Please enter the fahrenheit temperture:\n");
scanf("%d", &uent);
sol = frac*(uent-32);
printf("The temperture in celsius is: %d\n", sol);
}
else if (y == 2) {
int uent, sol;
float frac;
frac = 1.8;
printf("Please enter the celsius temperture:\n");
scanf("%d", &uent);
sol = (frac*uent)+32;
printf("The temperture in fahrenheit is: %d\n\n", sol);
}
getchar();
return 0;
}