# Thread: End of user input must be 999

1. ## 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?

2. You will prompt the user to enter a series of numbers. You will then read numbers until a 999 is read.

3. 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?
Use scanf to read integers until you read 999.

4. 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.

5. Originally Posted by BEN10
Use scanf to read integers until you read 999.
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..
please please please give me an example.. =)

6. scanf("%d", &myvar);
You can look at the documentation for scanf what parameters it accepts and what they mean.

7. 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..
please please please give me an example.. =)
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.

8. 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.

9. 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.

10. Really? Then what was the purpose of the last bit?
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.

11. ## 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..

12. 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 -

Ask the user for input.
Check the input.
If it is not 999, store it.
otherwise
stop asking for input.

13. Originally Posted by Elysia
Really? Then what was the purpose of the last bit?
Again I got misunderstood. 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.

14. Alright, no worries.

15. 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.

Popular pages Recent additions