By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,652 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

problem

P: n/a
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.

May 9 '07 #1
Share this Question
Share on Google+
28 Replies


P: n/a
ka************@yahoo.com said:
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.
By writing a C program, testing it, and executing it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
May 9 '07 #2

P: n/a
ka************@yahoo.com wrote:
Dear sir,
Please don't multi-post on Usenet.

--
Ian Collins.
May 9 '07 #3

P: n/a
On 9 Maj, 11:26, kapil_ghai2...@yahoo.com wrote:
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.
In case no one replied. Here's a solution that works for me:

#include <stdio.h>

int main(int argc, char * argv[])
{
int number;
int counter;

printf("Enter number >");

scanf("%d", &number);

/* allow values 1-99 only */
if (number 0 && number < 100)
for(counter = 0; counter < number; counter++)
printf("WELL DONE\n");
else
printf("bad number.");

return(0);
}

How I compiled it
C:\temp>gcc -ansi -pedantic well_done.c -o well_done.exe

Tw examples of usage:
C:\temp>well_done.exe
Enter number >foo
bad number.

C:\temp>well_done.exe
Enter number >2
WELL DONE
WELL DONE

Also see f.x:
http://en.wikibooks.org/wiki/C_Progr...put_and_Output

Also: try to solve your problems by using your favorite search engine
- you learn a lot from it.

/Per

--

Per Erik Strandberg
..NET Architect - Optimization
Tomlab Optimization Inc.
http://tomopt.com/tomnet/

May 9 '07 #4

P: n/a
ka************@yahoo.com wrote:
I want to input an integer value from keyboard and display on screen
"WELL DONE" that many times, how can i do this.
int main( void )
{
int n = getIntegerValueFrom( "keyboard" );
while (n 0) displayOnScreen( "WELL DONE" );
return 0;
}

Easy-peasy. Now you just have to write `getIntegerValueFrom` (note that
Standard C doesn't know about "keyboards") and `displayOnScreen` (note
likewise that Standard C doesn't know about "screens").

I'd read from `stdin` and write to `stdout` myself; it's portable.

--
"It is seldom good news." ~Crystal Ball~, /The Tough Guide to Fantasyland/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

May 9 '07 #5

P: n/a
per9000 <pe*****@gmail.comwrites:
On 9 Maj, 11:26, kapil_ghai2...@yahoo.com wrote:
>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.

In case no one replied. Here's a solution that works for me:
[code snipped]

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.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 9 '07 #6

P: n/a
<ot>
<perhaps also silly>

On 9 Maj, 12:42, Keith Thompson <k...@mib.orgwrote:
[...] 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.
You might be right. I should perhaps only have linked him to wikibooks/
C/simpleIO, but at least I DID link him to wikibooks/C/simpleIO :-)
All people were telling the kapil guy that his solution was:
- write a C program, test it, and execute it.
- Please don't multi-post on Usenet.

Not very helpful as I see it. It seems this list sometimes is h-bar:
hostile beyond all recognition. It seems the readers of this list are
willing to take the time to tell other people they are:
- stupid
- off topic
- not following comp.lang.c.netiquette

Why not just ignore a message you find stupid instead of replying? OK,
it does not feed the ego, but it's a lot easier. Or send a quick hint
like "scanf + printf" (like I should have done).

/Per

--

Per Erik Strandberg
..NET Architect - Optimization
http://tomopt.com/tomnet/

</perhaps also silly>
</ot>

May 9 '07 #7

P: n/a
per9000 <pe*****@gmail.comwrote:
Why not just ignore a message you find stupid instead of replying?
Because it does not teach the beginning schoolboy that getting someone
else to do your homework for you (as you did) is the perfect way to fail
three years on (so you did him a _great_ service - well done).

Richard
May 9 '07 #8

P: n/a
per9000 wrote:
On 9 Maj, 12:42, Keith Thompson <k...@mib.orgwrote:
>[...] 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.
<snip>
All people were telling the kapil guy that his solution was:
- write a C program, test it, and execute it.
<snip>
Not very helpful as I see it.
It's pretty useful if the OP takes it to heart. If they're
doing homework on C then you might imagine they'd be doing
a course on C, in which case it would work out better if
they actually try to learn C.

--
imalone
May 9 '07 #9

P: n/a
per9000 said:

<snip>
>
Why not just ignore a message you find stupid instead of replying?
Firstly, the message wasn't stupid, exactly. It appeared to be an
attempt by the OP to avoid doing his homework. Many people in clc
consider this to be dishonest, and are not shy about saying so.

Secondly, if you don't like the replies made by people like Keith, why
not just ignore them instead of replying? Because you had something to
say? Right. Well, so did Keith. And so did I.
OK, it does not feed the ego,
So what? The best help I can give the OP is to suggest that he writes
his own programs. Otherwise, he'll never learn how to write good C.
This isn't about ego, but about altruism. Anyone who is here for the
good of their ego is in the wrong place: comp.lang.c is notorious for
ego-busting.
but it's a lot easier. Or send a quick hint
like "scanf + printf" (like I should have done).
....but instead you wrote a program that demonstrated your lack of regard
for scanf's return value. So much for ego.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
May 9 '07 #10

P: n/a
>>>>"KT" == Keith Thompson <ks***@mib.orgwrites:

KTNobody else provided a solution for a very good reason. The
KToriginal poster was (apparently) asking us to do his homework
KTfor him. Providing a complete solution on a silver platter
KTdoesn't do anybody any favors.

Except for that the solution shows several hallmarks of having been
written by an experienced programmer; if the professor is any good
he'll twig to them immediately, and the student will be worse off.

Not that this justifies doing homework, but if you're going to do
someone's homework, it's worthwhile to make sure that it won't be
mistaken for his or her homework.

Charlton

--
Charlton Wilbur
cw*****@chromatico.net
May 9 '07 #11

P: n/a
On 9 Maj, 14:11, Richard Heathfield <r...@see.sig.invalidwrote:
[...]
...but instead you wrote a program that demonstrated your lack of regard
for scanf's return value. So much for ego.
[...]
It seems me/my ego has been smashed many times today. Just once could
have been random bad luck, but it seems I deserve it. I will repent.

/P

May 9 '07 #12

P: n/a
Chris Dollin wrote:
while (n 0) displayOnScreen( "WELL DONE" );
Grrrr. `while (n-- 0) displayOnScreen( "WELL DONE" );`.

I /thought/ the --. I just didn't /type/ it.

--
"What I don't understand is this ..." Trevor Chaplin, /The Beiderbeck Affair/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

May 9 '07 #13

P: n/a
Chris Dollin <ch**********@hp.comwrote:
while (n 0) displayOnScreen( "WELL DONE" );
Grrrr. `while (n-- 0) displayOnScreen( "WELL DONE" );`.
I /thought/ the --. I just didn't /type/ it.
I noticed the infinite loop and figured it was intentional - after
all, the OP never stated that the program was required to display
"WELL DONE" *exactly* n times. (Although I suppose it does beg the
question of why you would read a value for n and then not actually do
anything useful with it.)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
May 9 '07 #14

P: n/a
Christopher Benson-Manica wrote:
Chris Dollin <ch**********@hp.comwrote:
while (n 0) displayOnScreen( "WELL DONE" );
>Grrrr. `while (n-- 0) displayOnScreen( "WELL DONE" );`.
>I /thought/ the --. I just didn't /type/ it.

I noticed the infinite loop and figured it was intentional - after
all, the OP never stated that the program was required to display
"WELL DONE" *exactly* n times. (Although I suppose it does beg the
question of why you would read a value for n and then not actually do
anything useful with it.)
Well, if `n` is zero then no WELLDONE's get displayed. Is that useful?
(Probably is if you can't find the interrupt key.)

--
"We live for the One, you die for the One." Unsaid /Babylon 5/

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

May 9 '07 #15

P: n/a
ka************@yahoo.com wrote:
>
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.
Sure. Here's my initial untested version. You should probably add
some error checking. Let me know what grade you get on this assignment.

#include <stdio.h>

void main()
{
char *intbuf, *buffer;
int i;

printf("Enter an integer: ");
gets(intbuf);

buffer = (char *)malloc(sizeof("exit 999"));
sprintf(buffer,"exit %s",intbuf);
i = system(buffer2);

while ( i-- )
printf("WELL DONE");

}

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
May 9 '07 #16

P: n/a
per9000 <pe*****@gmail.comwrote:
int number;
int counter;
printf("Enter number >");
scanf("%d", &number);
/* allow values 1-99 only */
if (number 0 && number < 100)
for(counter = 0; counter < number; counter++)
printf("WELL DONE\n");
else
printf("bad number.");
This will only work by (bad?) luck: if the user didn't enter
a number you end up with testing some random value stored in
'number' (which could be a number between 1 and 99). Hint:
scanf() has a return value that tells you how many items
where matched. Moreover, what you output via the first call
of printf() could very well stay stuck in the internal buf-
fer, so the user may not see it. That's always a problem if
a line doesn't either end in a '\n' or you fflush() stdout.

Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
May 9 '07 #17

P: n/a
On Wed, 09 May 2007 10:38:30 -0400, Kenneth Brody <ke******@spamcop.net>
wrote:
>ka************@yahoo.com wrote:
>>
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.

Sure. Here's my initial untested version. You should probably add
some error checking. Let me know what grade you get on this assignment.

#include <stdio.h>

void main()
{
char *intbuf, *buffer;
int i;

printf("Enter an integer: ");
gets(intbuf);

buffer = (char *)malloc(sizeof("exit 999"));
sprintf(buffer,"exit %s",intbuf);
i = system(buffer2);

while ( i-- )
printf("WELL DONE");

}
There are, ah, a few problems with this code. You wouldn't be trying to
get the OP into trouble would you?
May 9 '07 #18

P: n/a
Charlton Wilbur <cw*****@chromatico.netwrites:
>>>>>"KT" == Keith Thompson <ks***@mib.orgwrites:

KTNobody else provided a solution for a very good reason. The
KToriginal poster was (apparently) asking us to do his homework
KTfor him. Providing a complete solution on a silver platter
KTdoesn't do anybody any favors.

Except for that the solution shows several hallmarks of having been
written by an experienced programmer; if the professor is any good
he'll twig to them immediately, and the student will be worse off.

Not that this justifies doing homework, but if you're going to do
someone's homework, it's worthwhile to make sure that it won't be
mistaken for his or her homework.
The traditional way to do that is to provide an obfuscated solution
that satisfies the requirements, but that the student is unlikely to
be able to understand or explain.

Such an approach is arguably unfair to the student who might fall for
it. I prefer simply to tell the questioner to do his own homework (or
perhaps to offer to submit the solution directly to the instructor).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 9 '07 #19

P: n/a
cr*@tiac.net (Richard Harter) writes:
On Wed, 09 May 2007 10:38:30 -0400, Kenneth Brody <ke******@spamcop.net>
wrote:
>>ka************@yahoo.com wrote:
>>>
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.

Sure. Here's my initial untested version. You should probably add
some error checking. Let me know what grade you get on this assignment.

#include <stdio.h>

void main()
{
char *intbuf, *buffer;
int i;

printf("Enter an integer: ");
gets(intbuf);

buffer = (char *)malloc(sizeof("exit 999"));
sprintf(buffer,"exit %s",intbuf);
i = system(buffer2);

while ( i-- )
printf("WELL DONE");

}

There are, ah, a few problems with this code. You wouldn't be trying to
get the OP into trouble would you?
Shhhhh!

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 9 '07 #20

P: n/a
Richard Harter wrote, On 09/05/07 16:37:
On Wed, 09 May 2007 10:38:30 -0400, Kenneth Brody <ke******@spamcop.net>
wrote:
>ka************@yahoo.com wrote:
>>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.
Sure. Here's my initial untested version. You should probably add
some error checking. Let me know what grade you get on this assignment.

#include <stdio.h>

void main()
{
char *intbuf, *buffer;
int i;

printf("Enter an integer: ");
gets(intbuf);

buffer = (char *)malloc(sizeof("exit 999"));
sprintf(buffer,"exit %s",intbuf);
i = system(buffer2);

while ( i-- )
printf("WELL DONE");

}

There are, ah, a few problems with this code. You wouldn't be trying to
get the OP into trouble would you?
He can't be, some of the lines are correct!
--
Flash Gordon
May 9 '07 #21

P: n/a
>>>>"KT" == Keith Thompson <ks***@mib.orgwrites:

(quoting me)
>Not that this justifies doing homework, but if you're going to
do someone's homework, it's worthwhile to make sure that it
won't be mistaken for his or her homework.
KTThe traditional way to do that is to provide an obfuscated
KTsolution that satisfies the requirements, but that the student
KTis unlikely to be able to understand or explain.

KTSuch an approach is arguably unfair to the student who might
KTfall for it.

I'm not so charitable; the student is doing something he knows is
unethical in the first place, so if he submits a solution he does not
understand and gets caught, it's his own fault. Especially if other
posters have admonished the student to do his own howmework.

Charlton
--
Charlton Wilbur
cw*****@chromatico.net
May 9 '07 #22

P: n/a
ka************@yahoo.com wrote:
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.
Short of writing your code for you, there is little to say beyond what
you have already written. We won't do your homework. As a hint,
though, you should write a program that does the following:
1) read an integer value from the standard input stream
2) write "WELL DONE" that many time to the standard output stream
There are, of course, no such concepts of "screen" or "keyboard" in C,
which deals with streams.
May 9 '07 #23

P: n/a
Kenneth Brody wrote:
ka************@yahoo.com wrote:
>>
I want to input an integer value from keyboard and display on
screen "WELL DONE" that many times, how can i do this.

Sure. Here's my initial untested version. You should probably
add some error checking. Let me know what grade you get on this
assignment.

#include <stdio.h>

void main() {
char *intbuf, *buffer;
int i;

printf("Enter an integer: ");
gets(intbuf);

buffer = (char *)malloc(sizeof("exit 999"));
sprintf(buffer,"exit %s",intbuf);
i = system(buffer2);

while ( i-- ) printf("WELL DONE");
}
(slightly reformatted). I assume you are trying to generate a
faulty program that looks more or less alright. If kapil is going
to use it he should have done so already.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 9 '07 #24

P: n/a
Keith Thompson <ks***@mib.orgwrote:
Charlton Wilbur <cw*****@chromatico.netwrites:
Not that this justifies doing homework, but if you're going to do
someone's homework, it's worthwhile to make sure that it won't be
mistaken for his or her homework.
Such an approach is arguably unfair to the student who might fall for
it.
"Let the cheater beware." It's no more unfair than it is to answer a
request for a term paper about thermodynamics with a document
consisting of that old "hell is exothermic" joke.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
May 10 '07 #25

P: n/a

"per9000" <pe*****@gmail.comha scritto nel messaggio
news:11*********************@q75g2000hsh.googlegro ups.com...
#include <stdio.h>

int main(int argc, char * argv[])
Why the hell isn't int main(void) ok here?
{
int number;
int counter;

printf("Enter number >");
What if stdin isn't flushed?
scanf("%d", &number);
What if I write "x" and hit return?
/* allow values 1-99 only */
if (number 0 && number < 100)
for(counter = 0; counter < number; counter++)
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 */)?
printf("WELL DONE\n");
What's wrong with puts("WELL DONE")?
else
printf("bad number.");
Don't have a program producing output not ending with a newline.
return(0);
I would return EXIT_FAILURE in the "bad number" case. YMMV.
}

May 11 '07 #26

P: n/a
In article <ln************@nuthaus.mib.org>, Keith Thompson
<ks***@mib.orgwrites
>per9000 <pe*****@gmail.comwrites:
>On 9 Maj, 11:26, kapil_ghai2...@yahoo.com wrote:
>>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.

In case no one replied. Here's a solution that works for me:
[code snipped]

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.
Oh bugger.... I am going to have to fully agree with Keith :-)

The only time it is acceptable to post code to this sort of question is
when it contains code the student clearly could not have done or does
something completely different.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

May 11 '07 #27

P: n/a
In article <11*********************@e65g2000hsc.googlegroups. com>,
ka************@yahoo.com writes
>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.
As I said in September 2005......
Hi to any students.

THIS is the model of how to ask for help with homework... Ask your
questions this way and you will get help!

In article <11**********************@g43g2000cwa.googlegroups .com>,
glitter boy <lo**@nerdshack.comwrites
>Ok so I have this class for C. I have to write this program for my
instructor,
1: clearly saying it is a home work question.
Pretending is it not does not work here. You are also likely to get
answers that, it you use them, will make it obvious that you did not do
the work yourself.
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
2: clearly state the problem to be solved.
People here are not mind readers. I you can't take the time to properly
explain the problem then no one will take the time to answer.
>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
3: clearly state what you are having a problem with. "It doesn't work"
or similar mean you are lazy and have not analysed the problem . Other
people will not either.

AND

here is what I have coded this so far.

#include <stdio.h>

#define FACTOR 2.54

int main (void)
4: Post your attempt at solving the problem.
No one is going to write code for you but if you have a go they will
point you in the write direction and suggest improvements or point out
the obvious errors

>and here is the page with my instructors algorithm
http://www.gibson.vero-beach.fl.us/c...all/prj02.html
5 any additional information.
If people don't get the same information you have one the problem they
could give you the correct answer to a different problem.
>sorry i cant explain this better i am just lost right now
6 Be polite. You are asking for help....
Full marks to Glitter Boy for this model question. This is why he has
got some serious and sensible help.

We should post his question to the FAQ as the model how to ask a
homework question.... though most students don't read it :-(

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

May 11 '07 #28

P: n/a
"Army1987" <pl********@for.itwrites:
"per9000" <pe*****@gmail.comha scritto nel messaggio
news:11*********************@q75g2000hsh.googlegro ups.com...
>#include <stdio.h>

int main(int argc, char * argv[])
Why the hell isn't int main(void) ok here?
"int main(void)" is the hell ok here.

"int main(int argc, char * argv[])" is also the hell ok here.

It's not necessary to specify the parameters if you don't use them,
and it may trigger a warning for some compilers, but it's perfectly
the hell legal.
>{
int number;
int counter;

printf("Enter number >");
What if stdin isn't flushed?
I think you mean stdout.
> scanf("%d", &number);

What if I write "x" and hit return?
Good point.
> /* allow values 1-99 only */
if (number 0 && number < 100)
for(counter = 0; counter < number; counter++)
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 */)?
Sure, that would work, but a for loop of the form:

for (i = 0; i < MAX; i ++)

is a very common idiom, and it makes it obvious that the body of the
loop will be executed exactly MAX times (assuming the body of the loop
doesn't do anything funny). If I saw your suggested "while (number--)
....", I'd have to take a moment to convince myself that it doesn't
execute number-1 or number+1 times.
> printf("WELL DONE\n");
What's wrong with puts("WELL DONE")?
Nothing. What's wrong with printf("WELL DONE\n")?

For beginning programmers, it's easier to introduce a single
general-purpose output function than to ask the student to keep track
of the confusing variety of output routines provided in <stdio.h>.
puts() may be more efficient than printf(), but I can almost guarantee
that the difference is insignificant. And some compilers will
translate printf("...\n") to puts("...").

> else
printf("bad number.");
Don't have a program producing output not ending with a newline.
Agreed.
> return(0);
I would return EXIT_FAILURE in the "bad number" case. YMMV.
>}
Agreed, but it's not a big deal in an assignment like this.

For the most part, you seem to be offering alternatives, not
improvements.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 11 '07 #29

This discussion thread is closed

Replies have been disabled for this discussion.