| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extreme Noobie Question :\
{Word}{up}
I've been trying to learn C on and off for quite some time now, but recently decided to make a more active effort. So, I have been working through an online tutorial ( whose URL I wont post as I haven't read the forum rules and do not know if posting of outside links is allowed ), but it seems to be a pretty straightforward tutorial. Other than the fact there is really no help whatsoever if you get stuck. Pretty much, at the end of each section it gives you some challenges to figure out. I am stuck on one such challenge. The object was to create a Farenheit to Celsius converter, that accepts the starting, stopping, and increase interval with the scanf function. Here is my code: #include <stdio.h> int main() { int a, b, c; printf("What temperature should I start?:"); scanf("%d", &a); printf("Starting Temp is %d!", a); printf("..."); printf("What temperature should I stop?:"); scanf("%d", &b); printf("I will stop at %d!", b); printf("What should the increase interval be?:"); scanf("%d", &c); printf("Start at %d, stop at %d, and increase by %d!", a, b, c); while (a <= b); { printf("%4d degrees F = %4d degrees C\n", a, (a - 32) * 5 / 9); a = a + c; } return 0; } I added the extra printf commands after the scanf to see whether or not scanf had some rules I did not know about. Such as scanf can only keep one variable at a time or some such newbie nonsense. Line 15 shows everything completely, so the extra printf's are completely unneccesary I know. Anyway, the problem is, it displays line 15, and then just sits there, doing nothing. Everything compiles fine, no errors or anything, so, I am at a loss. Any help would be appreciated. RathMon |
|
#2
|
|||
|
|||
|
Observe that you wrote [code]while(a <= b) ; [code]. The semicolon makes a while loop to run for one time only.
|
|
#3
|
|||
|
|||
|
Ha. That fixed it. Muchos gracias.
|
|
#4
|
|||
|
|||
|
Quote:
Muchas gracious -- what does it mean and what language is it?? Anyway welcome and continue to ask doubts. ![]() |
|
#5
|
|||
|
|||
|
I cant justify the correctness of the spelling, but it was intended to be spanish for Thank You, or the like.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Extreme Noobie Question :\ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|