hey I need help. I made one code but doesn't work!!!
Can we see what you have done so far?
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
needhelpe> yes I know that. but how can I make it work?
A loop is needed to continuously repeat the question until the stop signal (3.14) is reached.
If I would want to ask for a digital until the number five is entered I could write it like this:
#include <stdio.h>
int main(void)
{
int result = 0;
/*
* continuously asks for input until 5 is entered
*/
while (result != 5) {
int c;
/* repeat the question each time */
fputs("Enter a number: ", stdout);
fflush(stdout);
/* minimum error checking for entered input */
if (scanf("%d", &result) == 1) {
/* if correct, input is displayed */
printf("You entered: %d\n", result);
} else {
/* input was wrong, clear standard input */
while((c = getchar()) != '\n');
}
}
return 0;
}
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314