Thread: problem with program

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    99

    problem with program

    Hello
    Whenever user enter any number, then print the five value after the number. like if user enter 2 then program should be print 2,3,4,5,6 and if user enter 4 then program should be print 4,5,6,7,8

    there is condition user can enter only number between 0 to 10

    Code:
    #include<stdio.h>int main (void)
    {
     unsigned int i, number;
     
     printf("Enter number %d \n");
     
     scanf("%d",&number);
     
     if(number > 10)
     
     {
      if (i=0; i < 5; i++)
            {   
        printf("\n numbers %d", number);
      }
     }  
      return 0;
    }
    error: expected ')' before ';' token
    if (i=0; i < 5; i++)

    What do you think, what's the wrong in program?

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Perhaps the keyword "for" is more appropriate than "if" for executing a loop

    Also, you probably want to run the loop if the number is <= 10 rather than > 10

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    99
    Quote Originally Posted by Hodor View Post
    Perhaps the keyword "for" is more appropriate than "if" for executing a loop
    I got it

    Code:
    #include<stdio.h>
    int main (void)
    {
     unsigned int i, number;
     
     printf("Enter number %d \n");
     
     scanf("%d",&number);
     
     if(number <= 10)
     
     {
      for (i=number; i < number+5; i++)
            {   
        printf("\n numbers %d", i);
      }
     }  
      return 0;
    }
    Enter number 4200784
    3
    numbers 3
    numbers 4
    numbers 5
    numbers 6
    numbers 7

    what is 4200784 ?

  4. #4
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    4200784 is a random number because printf is expecting an integer ("%d") and you didn't supply one

  5. #5
    Banned
    Join Date
    Aug 2017
    Posts
    861
    your [rintf are off you have an unsigned int and are telling printf to use int, and the first printf is
    Code:
     printf("Enter number %d \n");
    saying you're going to use an int but you do not even need that %d there, and change all of your other %d to %u for unsigned also.

    Code:
     if(number <= 10)
    if you're suppose to go up to 10 and if they type 7 and you're doing number + 5, that gives you 12. yes?
    then you'll need to rethink your for loop conditional as well, yes?
    Last edited by userxbw; 12-07-2017 at 07:10 AM.

  6. #6
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by userxbw View Post
    if you're suppose to go up to 10 and if they type 7 and you're doing number + 5, that gives you 12. yes?
    then you'll need to rethink your for loop conditional as well, yes?
    Where do they say they're only supposed to go up to 10?

  7. #7
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Hodor View Post
    Where do they say they're only supposed to go up to 10?
    Now I am questioning your ability to even understand code, let alone yourself or other humans.
    this is called implied
    Code:
     if(number <= 10)
    Not explicit.

    2. they where simple yes or no QUESTIONS not statements.

    ( you're just coming in here taking pot shots at me now)
    Last edited by userxbw; 12-07-2017 at 07:15 PM.

  8. #8
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by userxbw View Post
    Now I am questioning your ability to even understand code, let alone yourself or other humans.
    this is called implied
    I am seriously wondering why you think that the OP should not print numbers greater than 10.

  9. #9
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Hodor View Post
    I am seriously wondering why you think that the OP should not print numbers greater than 10.
    seriously huh? try not to lose any sleep over it because I'm not, nor was I seriously thinking he couldn't go above 10. Where did you even get that impression? Ridged thinking perhaps, or you have yet to grasp the basic understanding of the difference between a question and a statement, or both? <-- notice the punctuation mark.
    I'm done with this conversation. get some professional help with your issues.
    Last edited by userxbw; 12-07-2017 at 10:38 PM.

  10. #10
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by userxbw View Post
    seriously huh? try not to lose any sleep over it because I'm not, nor was I seriously thinking he couldn't go above 10. Where did you even get that impression? Ridged thinking perhaps, or you have yet to grasp the basic understanding of the difference between a question and a statement, or both? <-- notice the punctuation mark.
    I'm done with this conversation. get some professional help with your issues.
    I think you may need professional help. This is the completely insane statement you made:
    Quote Originally Posted by userxbw
    if you're suppose to go up to 10 and if they type 7 and you're doing number + 5, that gives you 12. yes?
    then you'll need to rethink your for loop conditional as well, yes?
    no?
    no?
    NOWHERE did anyone say that the output must only go up to 10. You made it up.

  11. #11
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Hodor View Post
    I think you may need professional help. This is the completely insane statement you made:

    no?
    no?
    NOWHERE did anyone say that the output must only go up to 10. You made it up.
    and you're an idiot. then why would he even bother to do and if <= 10 if the amount he is running it up to does not matter? you sense of logic and just loving to be a ........y head trying to point out questions I asked to clarify just to try cut me down and make me feel like I'm the idiot for asking questions. Just so you can try to make yourself feel like you're smarter. Why don't you try to show some intelligence instead and go seek help like I said.

    you're just proving me right about what I asked you about and you regressed into the most basic sate of denial the first line of defense.

    Just like I said you "Ridged thinking (on your part) perhaps, and you have yet to grasp the basic understanding of the difference between a question and a statement, "

    You're the only one getting disturbed over it, why is that? The OP is not. He is the only one that actually has rights say something about it, it was to the OP not you, and they are questions, so it does not matter what I said, they were questions, not a statements. Stop being stupid. seriously go get help for your inferiority complex, and go back to school while you're at it.
    Last edited by userxbw; 12-08-2017 at 05:04 AM.

  12. #12
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by userxbw View Post
    and you're an idiot. then why would he even bother to do and if <= 10 if the amount he is running it up to does not matter? you sense of logic and just loving to be a ........y head trying to point out questions I asked to clarify just to try cut me down and make me feel like I'm the idiot for asking questions. Just so you can try to make yourself feel like you're smarter. Why don't you try to show some intelligence instead and go seek help like I said.

    you're just proving me right about what I asked you about and you regressed into the most basic sate of denial the first line of defense.

    Just like I said you "Ridged thinking (on your part) perhaps, and you have yet to grasp the basic understanding of the difference between a question and a statement, "

    You're the only one getting disturbed over it, why is that? The OP is not. He is the only one that actually has rights say something about it, it was to the OP not you, and they are questions, so it does not matter what I said, they were questions, not a statements. Stop being stupid. seriously go get help for your inferiority complex, and go back to school while you're at it.
    I don't like school

  13. #13
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Hodor View Post
    I don't like school
    it shows, nor is it an excuse to NOT self educate yourself in more than just programming.

    Read geographic item location data from file and calculate neighbors

    post 13, and 14
    Last edited by userxbw; 12-08-2017 at 05:20 AM.

  14. #14
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,787
    Quote Originally Posted by userxbw View Post
    it shows, nor is it an excuse to NOT self educate yourself in more than just programming.

    Read geographic item location data from file and calculate neighbors

    post 13, and 14
    I invite you to solve the problem of combining the trees where appropriate. See post #1 of the thread you linked to

  15. #15
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Hodor View Post
    I invite you to solve the problem of combining the trees where appropriate. See post #1 of the thread you linked to
    it has nothing to do if I can write that code or not in the other post,
    the point was you're writing it in c and its c++ then your cause yourself into self admitted state of confusion over what OP really needs to the point that you actually admit that you should have asked a QUESTION first.

    so here I did this in this post , asked a question first before going through all of what one could have on an assumption, and you're making it into a federal case out of it, only turning yourself into a hypocrite because of it. stop being stupid.
    Last edited by userxbw; 12-08-2017 at 06:20 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Problem
    By chanhalzkie in forum C Programming
    Replies: 8
    Last Post: 12-13-2012, 08:54 AM
  2. Replies: 4
    Last Post: 10-16-2008, 07:30 PM
  3. Problem with my little program.
    By RainbowStar in forum C++ Programming
    Replies: 6
    Last Post: 07-08-2007, 10:07 AM
  4. problem with program
    By robasc in forum C++ Programming
    Replies: 5
    Last Post: 04-19-2006, 03:13 PM
  5. Math Equation Program (I can't find the problem with my program!)
    By masked_blueberr in forum C Programming
    Replies: 14
    Last Post: 07-06-2005, 11:53 AM

Tags for this Thread