End of user input must be 999

This is a discussion on End of user input must be 999 within the C Programming forums, part of the General Programming Boards category; hey there.. need ur guys help here.. ok.. let me give u guys my question so that it will be ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Location
    Malaysia, Cyberjaya
    Posts
    38

    Question 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. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You will prompt the user to enter a series of numbers. You will then read numbers until a 999 is read.

  3. #3
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by naspek View Post
    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.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Jul 2009
    Location
    Malaysia, Cyberjaya
    Posts
    38
    Quote Originally Posted by BEN10 View Post
    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. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    scanf("%d", &myvar);
    You can look at the documentation for scanf what parameters it accepts and what they mean.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by naspek View Post
    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.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Elysia View Post
    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.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    Really? Then what was the purpose of the last bit?
    Quote Originally Posted by BEN10 View Post
    Actually to read a list of numbers until 999, you will have to use a loop with the condition being num!=999.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Registered User
    Join Date
    Jul 2009
    Location
    Malaysia, Cyberjaya
    Posts
    38

    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. #12
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    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.
    Last edited by Spidey; 07-15-2009 at 03:55 AM.

  13. #13
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Elysia View Post
    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.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  14. #14
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    Alright, no worries.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    602
    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.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with error checking on input from user.
    By NuNn in forum C Programming
    Replies: 8
    Last Post: 01-23-2009, 11:59 AM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  3. Modify to make Doubly Linked List
    By Dampecram in forum C Programming
    Replies: 10
    Last Post: 11-03-2008, 06:25 PM
  4. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 09:53 AM
  5. Ending user input with # character
    By jowatkins in forum C++ Programming
    Replies: 2
    Last Post: 04-27-2004, 10:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21