prompt user for number of loops

This is a discussion on prompt user for number of loops within the C Programming forums, part of the General Programming Boards category; Originally Posted by quzah But you're wrong. His sample code does work. You said it didn't. You're wrong. They're still ...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by quzah
    But you're wrong. His sample code does work. You said it didn't. You're wrong. They're still filling n, they've just used a #define for part of the middle loop condition. The point is, you're wrong. Your description of what the #define does in their code is wrong. You were wrong. They were right. I pointed it out.

    I'm not "getting" a rep. I already have one. I've been here for eight years or something like that. I'm well past the "getting a rep" stage, and were anyone to pay attention, they'd notice I quite clearly don't care.


    Quzah.
    No, you're not reading the problem correctly. (Again). This was the problem:

    prompt user for number of loops

    how do i prompt a user to choose the number of loops they want.

    for example, I know that if I set #define MAXCOUNT 100, it will loop 100 times. What would i put for the user to select the number of times they want it to loop?
    Yes, the code given will allow the user to choose the number of "loops they want", BUT NO, it will not allow them to define that number in advance, as a defined VALUE, and then allow the user to modify that VALUE.

    You can scream "I'm right and you're wrong", until you're blue in the face. It just won't make it true.

    Adak

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by Adak
    BUT NO, it will not allow them to define that number in advance, as a defined VALUE, and then allow the user to modify that VALUE.
    But then, nobody asked for that feature. (Whatever it means.)

    Don't argue with Quzah. Really. He's got this annoying habit of making certain he's really right before posting, and even more so before getting into a discussion. I've never been able to prove him wrong on anything but minor details.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Yeah, he's one of the forum gods.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  4. #19
    Registered User
    Join Date
    Sep 2006
    Posts
    41
    Quote Originally Posted by manutd
    Yeah, he's one of the forum gods.
    i tried it to see, and all it did was scroll from 4900 until forever. What i need to do is lets say you are a teacher, and you have a X number of students, you want a program that calculates the class average, so how do i prompt the user to say ok, i have 25 students, and then enter your 25 grades as prompted, then it will print out the average. The only part is how do i get to the prompt part first.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak
    No, you're not reading the problem correctly. (Again).
    I most definately did read the problem. The sample code provides exactly this:
    Quote Originally Posted by Adak
    This was the problem:

    prompt user for number of loops
    Yes, yes it was. Oh, by the way, that sample code we were talking about... yeah, that's exactly what it does.
    Quote Originally Posted by Adak
    Yes, the code given will allow the user to choose the number of "loops they want",
    Well at least we can agree on something.
    Quote Originally Posted by Adak
    BUT NO, it will not allow them to define that number in advance, as a defined VALUE, and then allow the user to modify that VALUE.
    What? What are you talking about? No one wanted to define a number in advanced and then have them pick a different one. That wasn't anywhere in the problem description. You're just making stuff up in an effort not to be wrong. That's just silly. No one wanted that but you.
    Quote Originally Posted by Adak
    You can scream "I'm right and you're wrong", until you're blue in the face. It just won't make it true.
    You just keep telling yourself that.

    To further the point, I'll provide a full explanation of the origional post, since you've decided to start quoting fragments of text to support your fiction:
    Quote Originally Posted by wonderpoop
    how do i prompt a user to choose the number of loops they want.

    for example, I know that if I set #define MAXCOUNT 100, it will loop 100 times. What would i put for the user to select the number of times they want it to loop?
    This means:

    "I don't know how to prompt the user for a number, which will be used to control the number of loop executions. For example, I know if I use a #define, I can then insert that into a loop, like so:
    Code:
    #define MAXCOUNT 100
    int x;
    for( x = 0; x < MAXCOUNT; x++ )
    However, I am not sure how to replace the MAXCOUNT portion with a number that the user chooses instead."

    Reading comprehension for the win! I mean, come on! That was easy to understand. They .... ah, that's it, isn't it? They used complete sentences, punctuation, and while they did slip in a lower case i, they didn't use enough "u", "omg", "plz", "k", "thx" and the like. Typical.

    Quote Originally Posted by CornedBee
    But then, nobody asked for that feature. (Whatever it means.)
    See, CornedBee can comprehend the OP's post. What's your problem? Oh, right, he's not trying to prove he's right, like you are. Even though you say you're really not. *snicker*
    Quote Originally Posted by CornedBee
    Don't argue with Quzah. Really. He's got this annoying habit of making certain he's really right before posting, and even more so before getting into a discussion. I've never been able to prove him wrong on anything but minor details.
    As I like to put it, "Never argue with a pedant."

    That being said, I am occasionally wrong. Just not now.


    Quzah.
    Last edited by quzah; 11-12-2006 at 09:26 PM.
    Hope is the first step on the road to disappointment.

  6. #21
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by wonderpoop
    i tried it to see, and all it did was scroll from 4900 until forever. What i need to do is lets say you are a teacher, and you have a X number of students, you want a program that calculates the class average, so how do i prompt the user to say ok, i have 25 students, and then enter your 25 grades as prompted, then it will print out the average. The only part is how do i get to the prompt part first.
    So take a moment to think about how you'd get it to use that number. It's really quite simple:
    Code:
    ask for number
    store number in variable
    
    loop using that number as shown
        do stuff
    Just don't change the value of the variable after you've read it in. Then use that variable, as illustrated in the first example, and many times afterwards, to control loops as you please.

    Post some code if you still can't figure out. Be sure to explain what it is you want. Be sure to use tiny words, so that maybe this time Adak will be able to follow along. (Just between you and I, he seems to be a little slow in the head. If you know what I mean. )


    Quzah.
    Last edited by quzah; 11-12-2006 at 09:25 PM.
    Hope is the first step on the road to disappointment.

  7. #22
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quzah posted:
    What? What are you talking about? No one wanted to define a number in advanced and then have them pick a different one. That wasn't anywhere in the problem description. You're just making stuff up in an effort not to be wrong. That's just silly. No one wanted that but you.
    One more time for Quzah, who can program, but can't comprehend plain english:

    From the thread's originator:
    #include <stdio.h>
    #include <math.h>
    #define MAXCOUNT 5 <- I want this number to be chosen by the user
    Can you see the little "I want this number..." Quzah? Can you see that the little arrow is pointing RIGHT AT the #define MAXCOUNT variable?

    Can you not see that MAXCOUNT is EXACTLY the variable that he was AT THAT MOMENT, asking if it could be chosen by the user?

    You of course, took it to mean something more practical for programming purposes. I understand; but don't call me names because I took it to mean EXACTLY WHAT THE OP WROTE.

    That's what he wrote - and that's what I answered.

    Adak

  8. #23
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak
    One more time for Quzah, who can program, but can't comprehend plain english:

    From the thread's originator:
    Nice try, but you fail. Read the first post. I can selectively quote pieces I need to make my argument, but I don't have to. My point has already been made. It was made in the first post, with the first reply being the correct answer.
    Quote Originally Posted by wonderpoop
    how do i prompt a user to choose the number of loops they want.

    for example, I know that if I set #define MAXCOUNT 100, it will loop 100 times. What would i put for the user to select the number of times they want it to loop?
    See that? First post, first line. "How do I prompt a user to choose the number of loops they want. Bam! Reading comprehension for the win! First post second line, "I know that if I set #define MAXCOUNT 100 it will loop 100 times. What would I put for the user to select the number of times they want it to loop?

    You fail, moron. It was asked and answered in the first post.

    Next, you say:
    Quote Originally Posted by Adak
    Nope, sorry. This dog will never hunt.
    100% false! ........ing copy-paste, compile. It works. You're wrong.
    Quote Originally Posted by Adak
    The value of n, is not known at this time, (the program hasn't even been compiled yet), and it could never be inserted into your code.
    The only way you are even remotely correct here is if you're trying to say your understanding of what the origional poster really wanted is:

    "I want the user to be able to edit the line "#define MAXCOUNT x" so that they can compile the program with their own hard coded value."


    Quzah.
    Last edited by quzah; 11-14-2006 at 04:20 AM.
    Hope is the first step on the road to disappointment.

  9. #24
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quzah wrote:

    The only way you are even remotely correct here is if you're trying to say your understanding of what the origional poster really wanted is:

    "I want the user to be able to edit the line "#define MAXCOUNT x" so that they can compile the program with their own hard coded value."
    DING DING DING DING DING DING!!!
    We have a Winner!!!


    That's EXACTLY what the OP help arrow pointed to, and that's EXACTLY what I took it to mean.

    Adak

  10. #25
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    If you want to argue with the most venerable, perfect, correct, distinguished member on this board, at least do it without the big red slushy font.

    To wonderpoop, one more time,
    Code:
    assume you have a number X
    scanf("%d", &X);
    
    for(i = 0; i < X; ++i)
    {
        /* instead of looping MAXCOUNT times, this will now loop X times, */
        /* simply because you replaced MAXCOUNT with X. Got it? */
    }
    Last edited by jafet; 11-15-2006 at 04:07 AM.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  11. #26
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Adak, what are you thinking? Quzah is right, he takes the time to formulate his answers, and he doesn't use size 100 red font.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  12. #27
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,852
    *warms hands on the nice glow of the flames in this post*
    Toasty.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

Similar Threads

  1. Loops Trouble
    By rlframpton in forum C Programming
    Replies: 2
    Last Post: 04-17-2009, 02:08 AM
  2. timed user input
    By sainiabhishek in forum C Programming
    Replies: 4
    Last Post: 04-01-2009, 12:59 PM
  3. Control characters to emulate a prompt?
    By xconspirisist in forum Windows Programming
    Replies: 3
    Last Post: 02-08-2006, 04:16 PM
  4. Changing this to user prompt help.
    By Infuriate in forum C Programming
    Replies: 5
    Last Post: 12-04-2005, 05:01 PM
  5. Newbie Help: Currency Converter
    By Ashfury in forum C Programming
    Replies: 10
    Last Post: 11-06-2005, 01:21 PM

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