Thread: Need study help : /

  1. #1
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Need study help : /

    Some of the questions on our study guide are really vauge and im not sure how to answer them. I dont want answers, jus a nudge in the right directions.

    6) Are there segments of code that must be defined above all others? yes of course...but thats alot of things If so, which ones? umm...yea...

    23) Explain the empty for loop (; :

    Gee if she ever taught that i might be able too.....

    24) Name the parts of a C++ program:

    Want a book?

    56) Explain why and when to use a continue statement:

    Wow, i dont think she payed attention in class cuz she never taught that one either

  2. #2
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    For first, whats first thing you define in a program.
    for second repost with diabled smillies
    Third i duno

  3. #3
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    1) typically pre-processor directives

    2) Explain the empty for loop (; :)

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    >typically pre-processor directives

    well, when you #include<iostream>, you're defining cout (along with alot of other things), so Iamien is still right...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    > Are there segments of code that must be defined above all others?

    what happens if you define a function after main without a prototype?

    >Explain why and when to use a continue statement

    your in a loop that does stuff. at some iteration you realize "crap, i dont want to do stuff this iteration" using 'continue' basically jumps to the bottom of the loop, skipping the code. the loop then moves on to its next iteration. did that make sense? heres an example

    Code:
    for(int i = 0; i < MAX; i++)
    {
          if( (i % 2) == 0 )
              continue;
    
          cout << i << ", ";
    }
    output:

    1, 3, 5, 7, ...

  6. #6
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by major_small
    >typically pre-processor directives

    well, when you #include<iostream>, you're defining cout (along with alot of other things), so Iamien is still right...
    umm its the same thing. I said pre-processor directives, header files ARE PP-directives...and they arent' always the first thing. Pragma comments sometimes come first, for example.

    Thanks perspective.

  7. #7
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    have you really never used a continue statement? i thought someone like you would have already....

    its just where you skip to the end of a loop

  8. #8
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    no, to be dead honest i had never even heard of it till the other day, i guess i just missed it? Thanks for the info guys.

  9. #9
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Originally posted by RoD
    umm its the same thing. I said pre-processor directives, header files ARE PP-directives...and they arent' always the first thing. Pragma comments sometimes come first, for example.

    Thanks perspective.
    that's exactly what I said... try reading the post...


    question: how far can break; and continue; go? do they just go to the nearest loop? or do they go one level up... i.e. if they're in a nested IF, do they stop the IF containing the IF they're in?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  10. #10
    Registered User
    Join Date
    Feb 2003
    Posts
    162
    empty for loop is basically to have a controlled infinitive loop...

    for the parts of a c++ program, how advanced is this class? by the looks of it, its pretty basic, so i'd just go with function prototypes, main, and function declarations
    Last edited by Jamsan; 05-29-2003 at 09:17 AM.

  11. #11
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Originally posted by major_small
    question: how far can break; and continue; go? do they just go to the nearest loop? or do they go one level up... i.e. if they're in a nested IF, do they stop the IF containing the IF they're in?
    breaks have to be within a loop or a switch statement, and will immediately terminate the loop, and continues have to be in a loop, where they immediately jump to the bottom of the loop.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  12. #12
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Originally posted by Zach L.
    breaks have to be within a loop or a switch statement, and will immediately terminate the loop, and continues have to be in a loop, where they immediately jump to the bottom of the loop.
    oh okay... thanks alot... i got confused because of the breaks in the switch statement...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  13. #13
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Empty for-loop

    I might use an empty for-loop is there is more than one condition that causes an exit ("break") from the loop. Or, when the exit condition needs to be tested in the middle of the loop.

    Or maybe you want to exit the loop (and the function) with a "return"... maybe multiple returns depending on various conditions.

    Actually, when I want an infinite loop... I think I've used while(1) or do-while(1)

  14. #14
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    ok here is how i answered some questions, and a few new ones, test is tommorow before i go before the board:

    >>Name the parts of a C++ program

    Pre-processor directives, prototypes, data types, classes. functions,array's, sorts, etc

    >>Explain the empty for loop

    The counter is declared and initialized outside of the loop condition but referenced in conditional statements within the loop.

    int i = 0;

    for (; i < 5; i++)
    {
    ....
    }


    New Question:

    98) List the data types and number of bytes each:

    I have NO idea what the bytes are, but i listed char, int, double, float, bool, and string cuz we did those.

    New Question:

    101) Show code line to associate a txt file to outfile variable using append attribute:

    Ok i get this much:

    ofstream outfile;
    outfile.open("c:\\blah.txt");

    but whats the append attribute? Append is add to something right?

    Thanks guys i owe you....

  15. #15
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Originally posted by RoD
    >>Explain the empty for loop

    The counter is declared and initialized outside of the loop condition but referenced in conditional statements within the loop.

    int i = 0;

    for (; i < 5; i++)
    {
    ....
    }


    New Question:

    98) List the data types and number of bytes each:

    I have NO idea what the bytes are, but i listed char, int, double, float, bool, and string cuz we did those.

    New Question:

    101) Show code line to associate a txt file to outfile variable using append attribute:

    Ok i get this much:

    ofstream outfile;
    outfile.open("c:\\blah.txt");

    but whats the append attribute? Append is add to something right?

    Thanks guys i owe you....
    Empty loops are the same think as infinite loops. This is an example: for(;;)

    99) This is system dependent. Use cout<<sizeof(datatype); where datatype is the datatype you want to find the size of.

    101) Append means that the outputted text is added to the end of the the file. Check out this link.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Computer Science Study tips?
    By Pyroteh in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-18-2005, 05:04 PM
  2. c-program for a case study!!!
    By zodi in forum C Programming
    Replies: 6
    Last Post: 07-29-2005, 02:38 PM
  3. Good colleges for language study
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-16-2004, 08:30 PM
  4. Study Abroad
    By axon in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 09-17-2004, 12:13 AM
  5. Home study course on Visual C++, your opion please
    By 747ken in forum C++ Programming
    Replies: 9
    Last Post: 10-14-2003, 09:06 AM