Like Tree3Likes

Loops

This is a discussion on Loops within the C++ Programming forums, part of the General Programming Boards category; Hello. My teacher just started teaching us loops friday. Yay! Not really, that was me being sacarcastically happy. He cannot ...

  1. #1
    Rag
    Rag is offline
    Registered User
    Join Date
    Sep 2011
    Posts
    12

    Question Loops

    Hello. My teacher just started teaching us loops friday. Yay! Not really, that was me being sacarcastically happy. He cannot teach and I am not good at this so we do not make a good combination. D: Yeah..... I was wondering if anyone could help me get started.... Sorry and thanks.


    This is our first assignment (Still have 6 more, each one harder than the last.).....

    **** Write a password program. The user enters a String, and cannot continue with the program until they correctly get the password *******




    “All truths are easy to understand once they are discovered; the point is to discover them.”
    Last edited by Rag; 09-25-2011 at 01:02 PM.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Rag View Post
    He cannot teach and I am not good at this so we do not make a good combination.
    Actually; you make a perfect combination.

    I can't comprehend how you can comment on your teacher's incompetence without being familiar with the stuff yourself.

    Seriously, nobody is going to do your homework for you. Read the Rules first.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Rag
    Rag is offline
    Registered User
    Join Date
    Sep 2011
    Posts
    12
    Please, tell me how we make a perfect combination?
    And what do you mean? I cant say my teacher is incompetent? I have gone to the guy many times, given up many lunches, and still he has not helped me understand what we are doing, he once told my class "No sane teacher would have you do this with as little skills as I have given you."
    AND i have read the rules, I was not asking for anyone to do. Just asking for tips on how to get started with it. Sorry if I said it wrong. And sorry if I am percieved as rude or as an idiot in any way.

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Rag View Post
    Please, tell me how we make a perfect combination?
    And what do you mean? I cant say my teacher is incompetent? I have gone to the guy many times, given up many lunches, and still he has not helped me understand what we are doing, he once told my class "No sane teacher would have you do this with as little skills as I have given you."
    AND i have read the rules, I was not asking for anyone to do. Just asking for tips on how to get started with it. Sorry if I said it wrong. And sorry if I am percieved as rude or as an idiot in any way.
    Then learn the concepts on your own instead of being lazy . It is a matter of commonsense, not Rocket Science, to figure out how loops work.

    As for your current program, first think of how you'd have done it by hand..i.e you were accepting the passwords from someone.... and you'll find that you've understood what loops are.

    Also start reading Cprogramming.com: How to Get Started with C++
    Last edited by manasij7479; 09-25-2011 at 01:49 PM.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    He cannot teach and I am not good at this
    Two facts that are undoubtedly related

    Write a password program. The user enters a String, and cannot continue with the program until they correctly get the password
    Do you really not know how to do this?

    This is beyond simple... get string from keyboard, compare string to password, exit if they don't match...

  6. #6
    Rag
    Rag is offline
    Registered User
    Join Date
    Sep 2011
    Posts
    12
    I am not trying to be lazy, if I was I would not have spent the last 30 minutes looking over the web for tutorials ---- And I know it isnt rocket science to you but i SUCK at dev c++ so it feels like it to me D:

    Okay and thanks.

    And will do.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Come on, people, do we need to pick on this poor guy/gal who needs help?
    First, Rag, can you show what you've accomplished so far so that we can understand what you know and don't, and what exactly you are having trouble with.
    Is it syntax? Is it the logic, or the idea behind loops?
    Salem likes this.
    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.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Tater, stop this nonsense. Instead of being rude and offensive, start trying to help instead.
    And just for reference, I reported that post.
    Salem likes this.
    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
    Registered User
    Join Date
    Oct 2006
    Posts
    2,265
    ok, so you already know the steps that the program must accomplish:

    1. ask the user for input
    2. if input is equal to the password, continue. else return to step 1

    now you just need to translate those steps into C++ code.

    the tutorials on this site should help you with that.

  10. #10
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Elkvis View Post
    ok, so you already know the steps that the program must accomplish:

    1. ask the user for input
    2. if input is equal to the password, continue. else return to step 1

    now you just need to translate those steps into C++ code.

    the tutorials on this site should help you with that.
    I think you just provided an easy incentive to use goto, instead of loops.
    <Though I'd admit that I learnt it in that way too, before I found out the wonderful loops, it is possibly the way the brain analyzes the problem>
    Last edited by manasij7479; 09-25-2011 at 02:06 PM.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  11. #11
    Rag
    Rag is offline
    Registered User
    Join Date
    Sep 2011
    Posts
    12
    Thanks Elysia. I do not quite understand why I find it confusing. My teacher only showed us one example during class and it did not have to do with string. And i havent been looking for examples of what i was assigned, I was looking for tutorials to learn how to do loops. And all of them were int.

    This is the one he showed us:
    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    //x++, x+=, x-=
            int x=0, grade=0, total=0;
                   while (x <= 30)    
            {
                   cout<<x<<endl;
                   x+=3;
           }
           /*while (true)
           {
                       if(x % 3 ==0)
                            cout<<x<<endl;
           x++;
           }*/
           
        system("PAUSE");
        return EXIT_SUCCESS;
    }

  12. #12
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Do you understand this part?
    Code:
    while (x <= 30)
    {
                   cout<<x<<endl;
                   x+=3;
           }
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  13. #13
    Rag
    Rag is offline
    Registered User
    Join Date
    Sep 2011
    Posts
    12
    Code:
    while (x<=30) // saying while x is less then or equal to 30
    {
    cout<<x<<endl; // if x is equal to or less than 30
    x+=3; // x= x+1
    But i think my answer is wrong because it lists the multiplies of 3....

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Elysia View Post
    Tater, stop this nonsense. Instead of being rude and offensive, start trying to help instead.
    And just for reference, I reported that post.
    Sometimes the best lessons are the least comfortable ones.
    Programming is not an area of expertise where one can "loaf along" and be good at it, it requires a certain analytical mindset... and you don't get that from Google.

    Offending post removed.

  15. #15
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Rag View Post
    Code:
    while (x<=30) // saying while x is less then or equal to 30
    {
    cout<<x<<endl; // if x is equal to or less than 30
    x+=3; // x= x+1
    But i think my answer is wrong because it lists the multiplies of 3....
    Yes, you're indeed somewhat wrong.
    while(x<=30) says that the following block will keep executing repeatedly until that condition becomes false.
    and x+=3 //==> x = x + 3
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



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

Similar Threads

  1. Replies: 3
    Last Post: 06-01-2011, 04:19 PM
  2. loops, menu loops
    By gloworm in forum C Programming
    Replies: 17
    Last Post: 04-12-2010, 07:59 PM
  3. Help with C, loops
    By Bobbismal in forum C Programming
    Replies: 3
    Last Post: 09-12-2009, 06:07 AM
  4. help with loops
    By lpaolini436 in forum C Programming
    Replies: 8
    Last Post: 11-10-2006, 12:51 PM
  5. For Loops!!!
    By Nailogamer in forum C++ Programming
    Replies: 5
    Last Post: 08-14-2003, 06:46 PM

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