# End of user input must be 999

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 07-13-2009
naspek
End of user input must be 999
hey there.. need ur guys help here..
ok.. let me give u guys my question so that it will be clearer for u to help me.. =)

"Your program will prompt the userto enter a series of number and the last value
read is sentinel 999.(i.e to end input, the user must enter 999 as the last value"

how am i going to do this?
• 07-13-2009
tabstop
You will prompt the user to enter a series of numbers. You will then read numbers until a 999 is read.
• 07-13-2009
BEN10
Quote:

Originally Posted by naspek
hey there.. need ur guys help here..
ok.. let me give u guys my question so that it will be clearer for u to help me.. =)

"Your program will prompt the userto enter a series of number and the last value
read is sentinel 999.(i.e to end input, the user must enter 999 as the last value"

how am i going to do this?

• 07-14-2009
Elysia
It is very simple...
It means all you do is write some pseudo code on how you would do this logically, then translate it into code.
No tricky C stuff or anything.
• 07-14-2009
naspek
Quote:

Originally Posted by BEN10

ok... i dont know how to use scanf to read the integers..
actually.. this is just part of the full code.. but, i just cant figure out, how to solve this problem..
it may look simple for an experience programmer, but, for newbie like me,
it's kinda hard..
• 07-14-2009
Elysia
scanf("%d", &myvar);
You can look at the documentation for scanf what parameters it accepts and what they mean.
• 07-14-2009
BEN10
Quote:

Originally Posted by naspek
ok... i dont know how to use scanf to read the integers..
actually.. this is just part of the full code.. but, i just cant figure out, how to solve this problem..
it may look simple for an experience programmer, but, for newbie like me,
it's kinda hard..

Here's an example.
Code:

```int i; printf("Enter i"); scanf("%d",&i);```
Actually to read a list of numbers until 999, you will have to use a loop with the condition being num!=999.
• 07-14-2009
Elysia
You don't need to tell them how to do things logically. A programmer must be able to figure that out him-/herself.
Using loops and placing code in right positions are not solutions we should hand out.
• 07-14-2009
BEN10
Quote:

Originally Posted by Elysia
You don't need to tell them how to do things logically. A programmer must be able to figure that out him-/herself.
Using loops and placing code in right positions are not solutions we should hand out.

Actually my aim was to tell the OP that if he/she doesn't know how to use scanf, then it might be difficult to do this problem.
• 07-15-2009
Elysia
Really? Then what was the purpose of the last bit?
Quote:

Originally Posted by BEN10
Actually to read a list of numbers until 999, you will have to use a loop with the condition being num!=999.

• 07-15-2009
naspek
i still can't get it..
ok.. the program suppose to be like this..

Enter temperature readings in Fahrenheit (999 to end): 80 90 85
75 70 999

i dont know how to do the 999 at the last of the sentence..
• 07-15-2009
Spidey
Well, I'm assuming you've got the first part done since your posting it.
So, That means that you are reading in input and storing it somewhere right ?
So, all you have to do is think of a way to not read in more data if the user entered 999.
Try writing it in english and then work your way into code.

heres a simple example -

Check the input.
If it is not 999, store it.
otherwise
• 07-15-2009
BEN10
Quote:

Originally Posted by Elysia
Really? Then what was the purpose of the last bit?

Again I got misunderstood:eek:. Seriously I wasn't in a mood to provide the OP the solution to his/her query. Ok, now from the next time I'll be more cautious while posting.
• 07-15-2009
Elysia
Alright, no worries.
• 07-15-2009
slingerland3g
BEN10 - picture Elysia as a "watch hound" and what you did was equivalent to passing a note off during an exam!

She busted me once...or twice. No worries.

What would really get me is if the same OP, continued to post the same problem if after giving such guidance on how to write the code.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last