K
Keith Thompson
There are, ah, a few problems with this code. You wouldn't be trying to
get the OP into trouble would you?
Shhhhh!
There are, ah, a few problems with this code. You wouldn't be trying to
get the OP into trouble would you?
Such an approach is arguably unfair to the student who might fall for
it.
Dear sir,
I want to input an integer value from keyboard and display on screen
"WELL DONE" that many times, how can i do this.
Keith Thompson said:[code snipped]per9000 said:In case no one replied. Here's a solution that works for me:
Nobody else provided a solution for a very good reason. The original
poster was (apparently) asking us to do his homework for him.
Providing a complete solution on a silver platter doesn't do anybody
any favors.
Why the hell isn't int main(void) ok here?#include <stdio.h>
int main(int argc, char * argv[])
What if stdin isn't flushed?{
int number;
int counter;
printf("Enter number >> ");
scanf("%d", &number);
Since you never use counter, and you never use number after the/* allow values 1-99 only */
if (number > 0 && number < 100)
for(counter = 0; counter < number; counter++)
What's wrong with puts("WELL DONE")?printf("WELL DONE\n");
Don't have a program producing output not ending with a newline.else
printf("bad number.");
I would return EXIT_FAILURE in the "bad number" case. YMMV.return(0);
Dear sir,
I want to input an integer value from keyboard and display on screen
"WELL DONE" that many times, how can i do this.
>Ok so I have this class for C. I have to write this program for my
>instructor,
> where he has already posted the softcopy and algorithm. But
>my question is I have to convert meters to feet and in this I have to
>output not only the feet but also the inches
>now I think I have coded
>the feet calculation properly but. I don't know how to send the
>remainder to inches and than recalculate it and display that
>calculation
> here is what I have coded this so far.
>
>#include <stdio.h>
>
>#define FACTOR 2.54
>
>int main (void)
>
>and here is the page with my instructors algorithm
>http://www.gibson.vero-beach.fl.us/classes/cop2000/fall/prj02.html
>sorry i cant explain this better i am just lost right now
Army1987 said:Why the hell isn't int main(void) ok here?#include <stdio.h>
int main(int argc, char * argv[])
What if stdin isn't flushed?
What if I write "x" and hit return?
Since you never use counter, and you never use number after the
loop, what's wrong with while(number-- /* > 0, but not needed here
since we know here number is positive */)?
What's wrong with puts("WELL DONE")?
Don't have a program producing output not ending with a newline.
Agreed.
I would return EXIT_FAILURE in the "bad number" case. YMMV.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.