#include<stdio.h>
int conv(int F);
int main()
{
int F;
for(F=0; F<300; F=F+20);
{
scanf("%d",&F);
printf("%d, ",F);
printf("%d\n",conv(F));
}
}
int conv(int F)
{
return (F-32)*(5/9);
}
I am new to programming, and have been set a task to print a table of Fahrenheit values and equivalent Celsius values. This code I have written doesn't seem to work and I'm not sure why?
3 replies to this topic
#1
Posted 20 March 2011 - 02:07 PM
|
|
|
#2
Posted 20 March 2011 - 02:36 PM
Because you overwrite value of F when you read input (scanf function). And remove that semicolon after for. Also, in your converting function you have to multiply by floating point number because integer division of 5 / 9 is 0.
A conclusion is where you got tired of thinking.
#define class struct // All is public.
#3
Posted 20 March 2011 - 02:44 PM
Thank you--it's been driving me mad! I have actually got it spitting out values now, but every value after the comma is 0? I got rid of the scanf (don't think I needed it) and the semicolon after for, I think there's something wrong with my 'conv' function but I'm not sure what
#4
Posted 20 March 2011 - 02:47 PM
ahhh got it... thanks very much, it would have driven me mad
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









