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

Struggling Comp Sci Student

P: n/a
Hey everyone, I've got a computer science class and we're working on
C++. I am struggling with nested loops and have a really simple
assignment, but I can't get it to run the loop. I need to run a loop
that has someone guess at a number 5 times and if they get 45, it
tells them how many guesses they needed. It also has to tell them if
they leave the range of guesses from 0 to 100.

I need help.

Can somebody help me please!!!

Stan.
Jul 19 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a

"Stan" <st******@netzero.net> wrote in message
news:82*************************@posting.google.co m...
Hey everyone, I've got a computer science class and we're working on
C++. I am struggling with nested loops and have a really simple
assignment, but I can't get it to run the loop. I need to run a loop
that has someone guess at a number 5 times and if they get 45, it
tells them how many guesses they needed. It also has to tell them if
they leave the range of guesses from 0 to 100.

I need help.

Can somebody help me please!!!


Sure, show us your code, we're happy to help.
We'll also need a bit more specific description of
the assignment than what you've written above.
-Mike
Jul 19 '05 #2

P: n/a
"Stan" <st******@netzero.net> wrote in message
news:82*************************@posting.google.co m...
Hey everyone, I've got a computer science class and we're
working on C++.
[...]


I believe there is a .students (or something similar) newsgroup
for C++ which might be more helpful.

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #3

P: n/a

"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
"Stan" <st******@netzero.net> wrote in message
news:82*************************@posting.google.co m...
Hey everyone, I've got a computer science class and we're
working on C++.
[...]


I believe there is a .students (or something similar) newsgroup
for C++ which might be more helpful.


I've never heard of .students groups, but I suppose
there could be some.

However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?
-Mike
Jul 19 '05 #4

P: n/a
"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
"Stan" <st******@netzero.net> wrote in message
news:82*************************@posting.google.co m...
Hey everyone, I've got a computer science class and we're
working on C++.
[...]


I believe there is a .students (or something similar) newsgroup
for C++ which might be more helpful.


Maybe you are thinking of alt.comp.lang.learn.c-c++, but I doubt it would be
more helpful. Beginners are welcome here too.

DW

Jul 19 '05 #5

P: n/a
Stan writes:
Hey everyone, I've got a computer science class and we're working on
C++. I am struggling with nested loops and have a really simple
assignment, but I can't get it to run the loop. I need to run a loop
that has someone guess at a number 5 times and if they get 45, it
tells them how many guesses they needed. It also has to tell them if
they leave the range of guesses from 0 to 100.


Something along these lines:

int guesses = 0;
while(guesses < 100)
{
/*your code*/
guesses = guesses + 1; // can be obfuscated
}

The detection of guesses that are out of range should be handled in the
block I call "your code". The message telling the user the number of
guesses he used is left to you.

Jul 19 '05 #6

P: n/a
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Gq*****************@newsread3.news.pas.earthl ink.net...
[...]
However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?


Because of my loyalty to the newsgroup fuhrer. Heil Fehrer!
Death to noobs! Ok, just kidding. It seems that Attila has
been fairly moderate lately, so now I look like the Newsgroup
Gestapo. Interesting turn of events. I don't object to anyone
who wants to help him. However, if there is an even more
topical newsgroup, I don't see how it is "chasing him away"
to refer to it.

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #7

P: n/a
"David White" <no.email@provided> wrote in message
news:YF******************@nasal.pacific.net.au...
[...]
Maybe you are thinking of alt.comp.lang.learn.c-c++,
Ah, yes, thank you. I was probably thinking of a Borland
newsgroup.
but I doubt it could be more helpful.
You would probably know better than I.
Beginners are welcome here too.


Good, because it's not always obvious who are beginners
here to begin with. ;)

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #8

P: n/a

"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Gq*****************@newsread3.news.pas.earthl ink.net...
[...]
However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?


Because of my loyalty to the newsgroup fuhrer. Heil Fehrer!
Death to noobs! Ok, just kidding. It seems that Attila has
been fairly moderate lately, so now I look like the Newsgroup
Gestapo. Interesting turn of events. I don't object to anyone
who wants to help him. However, if there is an even more
topical newsgroup, I don't see how it is "chasing him away"
to refer to it.


Per the FAQ, alt.comp.lang.learn.c-c++ is supposed to more newbie-friendly.
Jul 19 '05 #9

P: n/a
Mike Wahler wrote:
"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
"Stan" <st******@netzero.net> wrote in message
news:82*************************@posting.google. com...
Hey everyone, I've got a computer science class and we're
working on C++.
[...]


I believe there is a .students (or something similar) newsgroup
for C++ which might be more helpful.

I've never heard of .students groups, but I suppose
there could be some.

However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?


Erm, comp sci student, can't get a nested loop to work. I
know the comp sci depts all seem to be teaching java
nowadays ... but really.

Once had a 2nd year comp sci student ask "What's a dot aich
file?" 6 months into the course. Seems a group of them had a
tame final year student, who was banging out the assignments.

Jul 19 '05 #10

P: n/a
"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Gq*****************@newsread3.news.pas.earthl ink.net...
[...]
However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?


Because of my loyalty to the newsgroup fuhrer. Heil Fehrer!
Death to noobs! Ok, just kidding. It seems that Attila has
been fairly moderate lately, so now I look like the Newsgroup
Gestapo. Interesting turn of events. I don't object to anyone
who wants to help him. However, if there is an even more
topical newsgroup, I don't see how it is "chasing him away"
to refer to it.


Your reply as seen in full context (this group) gave
me that impression.

A referral to a more specific group is always a good
thing. But all Stan saw from you was essentially
"this is better asked elsewhere.", which imo he could
take to mean "not topical" or perhaps "expert level
stuff only here," neither of which of course is the case.

I wasn't trying to tell you what to do, and I certainly
don't feel you were rude or anything like that. I simply
didn't understand why you replied the way you did.
Now I know. No big deal. :-)

-Mike
Jul 19 '05 #11

P: n/a
"osmium" <r1********@comcast.net> wrote in news:bmjhqj$nklg1$1@ID-
179017.news.uni-berlin.de:
Stan writes:
[...]
Something along these lines:

int guesses = 0;
while(guesses < 100)
{
/*your code*/
guesses = guesses + 1; // can be obfuscated
}

The detection of guesses that are out of range should be handled in the
block I call "your code". The message telling the user the number of
guesses he used is left to you.


The specification said up to 5 guesses are allowed. Ordinarily this would
be a nit, but since it is for a beginner, it may be worth pointing out.
It might also be easier if the loop has two exit conditions instead of
one.

int guesses = 0;
bool success = false;

while ((guesses < 5) && !success))
{
/* Get number */
/* Report if out of range */
/* Otherwise see if it is correct */
guesses = guesses + 1;
}

/* Report number of attempts and whether user got it */

--
Gregg
Jul 19 '05 #12

P: n/a
WW
David B. Held wrote:
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Gq*****************@newsread3.news.pas.earthl ink.net...
[...]
However, many here (including myself) will be happy
to help this person. Looks like you're chasing him
away. How come?


Because of my loyalty to the newsgroup fuhrer. Heil Fehrer!
Death to noobs! Ok, just kidding. It seems that Attila has


Feher. And having a grandmother who was Jewish (well, she was catholic on
paper but then again she said Oh Yisrael and not Oh Jesus, which is a strong
hint) I take this bullshit of yours as a serious offense. And not a joke.

So I think it is time for you to apologize!

Calling someone a nazi is *not* a joke, in any way. So far I was amuzed by
your silly ways, but this is over the line. If you want to stay here ever
again as someone with a light chance to be respected, you will publicly
apologize! And this is not a joke either.

--
WW aka Attila
Jul 19 '05 #13

P: n/a
"WW" <wo***@freemail.hu> wrote in message
news:bm**********@phys-news1.kolumbus.fi...
David B. Held wrote:
[...]
Because of my loyalty to the newsgroup fuhrer. Heil
Fehrer! Death to noobs! Ok, just kidding.
Feher. And having a grandmother who was Jewish (well,
she was catholic on paper but then again she said Oh
Yisrael and not Oh Jesus, which is a strong hint) I take this
bullshit of yours as a serious offense. And not a joke.


So in order to be offended, you have to rely on speculative
ancestry? In that case, one of my ancestors might have
been a Jew also, and so I should be equally offended! Isn't
it time for Jews to stop complaining about something that
didn't even happen to them personally? Isn't it enough that
you got a special word out of it, and a state? I mean, the
millions of Poles, Slavs, Serbs, and other people killed by
the Nazis, Stalinists, Leninists, and every other brute in
history don't have a special term for their meaningless
deaths, but I've never once heard one of their ancestors
complain about it.
So I think it is time for you to apologize!
You mean it's time for you to censor me.
Calling someone a nazi is *not* a joke, in any way.
It is when "Nazi" is a placeholder for "authoritarian dictator",
and not "Jew burner". I could have used Castro, Stalin, or
even Mao, but people have a broader knowledge about
the Nazi infrastructure, so references to them are more
easily recognizable. Who knows what Castro's secret
police are called? And I thought "Feher" was a funny
play on "fuhrer", which is a generic term perfectly
describing my opinion of your behaviour sometimes.
From dictionary.com:

füh·rer also fueh·rer
n.

A leader, especially one exercising the powers of a tyrant.

I never said: "Fuhrer of the Third Reich," (though that
would not be an unreasonable inference, granted).
So far I was amuzed by your silly ways, but this is over the
line. If you want to stay here ever again as someone with a
light chance to be respected, you will publicly apologize!
This is merely fodder for my point. If you can't handle some
satirical criticism, I'm not going to placate your censoring
impulse with a contrived and insincere apology. That would
be insulting to you (since I don't regret saying it at all), and
would betray the very issue I was trying to highlight: that you
are an authoritarian tyrant.
And this is not a joke either.


Yes, that's what disturbs me the most. I never justified
genocide or any other atrocity, and yet you are unable
to separate the concept of a dictator from an event in
history. That is dangerous, because banning speech
about dictators merely creates the type of environment
in which said dictators prefer to operate in the first place.
Besides burning people, Hitler loved to burn books. And
refusing to allow people to condemn that behaviour
through satire is a sad indictment on "progressive"
humanity. Satire is the act of making a point through
analogy, exaggeration, and humor, all at once. It surely
runs the risk of offending some; but often, the point being
made is worth that risk.

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #14

P: n/a
sam

"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
been a Jew also, and so I should be equally offended! Isn't
it time for Jews to stop complaining about something that
didn't even happen to them personally?
so you mean i shouldn't take half of my grandmother's family being wiped out
personally ?
Isn't it enough that
you got a special word out of it, and a state?


wow , a word !!!! that really makes it all worth it...
and a state ? what kind of a state is it when terrorists are
blowing people up all the time ???
Jul 19 '05 #15

P: n/a
lilburne <li******@godzilla.net> spoke thus:
Once had a 2nd year comp sci student ask "What's a dot aich
file?" 6 months into the course. Seems a group of them had a
tame final year student, who was banging out the assignments.


Um, yikes? Although it was quite awhile after my first C course before I
really figured out what make was all about. Of course, that might have been
because they just gave us hugely complex makefiles and never told us how to
use them...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 19 '05 #16

P: n/a
WW
David B. Held wrote:
"WW" <wo***@freemail.hu> wrote in message
news:bm**********@phys-news1.kolumbus.fi...
David B. Held wrote:
[...]
Because of my loyalty to the newsgroup fuhrer. Heil
Fehrer! Death to noobs! Ok, just kidding.


Feher. And having a grandmother who was Jewish (well,
she was catholic on paper but then again she said Oh
Yisrael and not Oh Jesus, which is a strong hint) I take this
bullshit of yours as a serious offense. And not a joke.


So in order to be offended, you have to rely on speculative
ancestry?


No. That only adds to my disqust. Now apologize or shut up. You have
crossed the line. No big mouthed bullshit talk will take you out of this.

--
WW aka Attila
Jul 19 '05 #17

P: n/a

"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
You mean it's time for you to censor me.


It would be better if you would filter him. I did, and life is more
pleasant now.
Calling someone a nazi is *not* a joke, in any way.


Actually, by convention when it has a lower case 'n', it *is* used as a
joke. Seinfeld's soup nazi, anyone?
Jul 19 '05 #18

P: n/a
Christopher Benson-Manica wrote:
lilburne <li******@godzilla.net> spoke thus:

Once had a 2nd year comp sci student ask "What's a dot aich
file?" 6 months into the course. Seems a group of them had a
tame final year student, who was banging out the assignments.

Um, yikes? Although it was quite awhile after my first C course before I
really figured out what make was all about. Of course, that might have been
because they just gave us hugely complex makefiles and never told us how to
use them...


You can get a comp sci degree by drawing ER diagrams
(probably UML nowadays). You only need rudimentary
programming knowledge if at all.

Jul 19 '05 #19

P: n/a
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bm**********@chessie.cirr.com...
lilburne <li******@godzilla.net> spoke thus:
Once had a 2nd year comp sci student ask "What's a dot aich
file?" 6 months into the course. Seems a group of them had a
tame final year student, who was banging out the assignments.
Um, yikes? Although it was quite awhile after my first C course before I
really figured out what make was all about. Of course, that might have

been because they just gave us hugely complex makefiles and never told us how to use them...


'make' utilites are not part of C, although often used
as development tools with projects containing C programs.

'make' utilites need not be used with programming at all.
They simply implement 'rule based' batch processing.
I sometimes use them for things besides building programs.

I frequently see this failure to distinguish concepts by
CS students (and graduates!). Sigh.

-Mike
Jul 19 '05 #20

P: n/a
Mike Wahler <mk******@mkwahler.net> spoke thus:
'make' utilites are not part of C, although often used
as development tools with projects containing C programs. 'make' utilites need not be used with programming at all.
They simply implement 'rule based' batch processing.
I sometimes use them for things besides building programs. I frequently see this failure to distinguish concepts by
CS students (and graduates!). Sigh.


Believe me, I do know that C and C++ are not directly linked with make. I
just made the comment because make "makes" life much simpler for writing
projects of a reasonable size. (Was that a bad pun or what??). make is a
tool that programmers should know how to use (IMHO), but we didn't really
learn it. Believe me, I'm not trying to give you ulcers ;)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 19 '05 #21

P: n/a

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:fG***************@newsread4.news.pas.earthlin k.net...
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:bm**********@chessie.cirr.com...
lilburne <li******@godzilla.net> spoke thus:
Once had a 2nd year comp sci student ask "What's a dot aich
file?" 6 months into the course. Seems a group of them had a
tame final year student, who was banging out the assignments.


Um, yikes? Although it was quite awhile after my first C course before I really figured out what make was all about. Of course, that might have

been
because they just gave us hugely complex makefiles and never told us how

to
use them...


'make' utilites are not part of C, although often used
as development tools with projects containing C programs.

'make' utilites need not be used with programming at all.
They simply implement 'rule based' batch processing.
I sometimes use them for things besides building programs.

I frequently see this failure to distinguish concepts by
CS students (and graduates!). Sigh.


He didn't fail to distinguish <sigh>. make files are no more a "part of C"
than "dot aich files" are.
Jul 19 '05 #22

P: n/a
"sam" <sa*@cvisiontech.com> wrote in message
news:wd**********************@twister.nyc.rr.com.. .

"David B. Held" <dh***@codelogicconsulting.com> wrote in message
news:bm**********@news.astound.net...
been a Jew also, and so I should be equally offended! Isn't
it time for Jews to stop complaining about something that
didn't even happen to them personally?
so you mean i shouldn't take half of my grandmother's family
being wiped out personally ?


That's not what I said. You should take the *event* personally.
But relating every word uttered by every person as a statement
justifying that event is unreasonable.
Isn't it enough that
you got a special word out of it, and a state?


wow , a word !!!! that really makes it all worth it...


You get a word, with an entry in the dictionary for an event
that happened to your ancestors, and that isn't enough?
Here's the entry from dictionary.com, which in this case is
channeling The American Heritage Dictionary:

1. Great destruction resulting in the extensive loss
of life, especially by fire.

2.
a. Holocaust The genocide of European Jews and
others by the Nazis during World War II: “Israel
emerged from the Holocaust and is defined in relation
to that catastrophe” (Emanuel Litvinoff).

b. A massive slaughter: “an important document in
the so-far sketchy annals of the Cambodian
holocaust” (Rod Nordland).

3. A sacrificial offering that is consumed entirely by flames.

Note that the millions of Gentiles killed at or around the
same time get reduced to "others". Was their sacrifice
any less? Isn't it enough that your ancestors get singled
out for attention here? My point is that Slavs and Poles
and all the rest killed during WWII don't assume that
every reference to nazis justifies the Holocaust or any
other atrocity in history. And they lost just as many if not
more family members as any Jew.
and a state ? what kind of a state is it when terrorists are
blowing people up all the time ???


It's more of a state than the Palestinians have, for one. Are
you grateful for nothing?? But that's getting afar field. The
point is, I was not trying to make light of any atrocity in history,
nor to accuse someone of being a genocidal maniac. I was
merely equating Atilla with tyrrany, and I suspect I'm not the
only person who feels that way. His latest actions merely
reinforce that opinion.

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.