Thread: Random Test =D

Results 1 to 13 of 13
  1. #1
    Alroundeath's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    331
    Reputation
    8
    Thanks
    29
    My Mood
    Amused

    Random Test =D

    I've been reading through a book, and so far I've started to skim the surface of C++.
    I decided to start keeping a few notes, so I could refer back to them, and in return, I would answer them.

    Almost like Cornell Notes. Anyways, I wanted to post the questions and answers on here:
    1.) So the people who actually know, can check if they're right
    2.) SO people who don't know, can see if they know the answers

    I'll post the questions at the top, and the answers I got, at the bottom.

    I figure this might be a lil' fun, and a change from all the help topics x)

    Questions:

    1.) What is used compile .cpp files using the Visual Studio Command Prompt?:
    2.) How do you start a function?: (Not sure if you would call it a source, or what you would call it, but I understand what I mean xP )
    3.) How do you end a function?:
    4.) How would you use the header iostream?:
    5.) How would you declare the variable 'length'?:
    6.) How do you declare more than one variable without starting a new line?:
    7.) What does cout stand for?:
    8.) What does cin stand for?:
    9.) What is the << operator, and what does it do?:
    10.) What is the >> operator, and what does it do?:

    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    |
    Answers:
    1.) C:\...>cl -GX Sample.cpp
    2.) int main()
    3.) return 0;
    4.) #include <iostream>
    5.) int length;
    6.) int length, width;
    7.) Console Output(Mainly writing something on the computer screen)
    8.) Console Input(linked to the keyboard by default, can be linked to other input sources)
    9.) << is the output operator, it processes inputted data and gives an output
    10.) >> is the input operator, it inputs data into the program to be processed


    If my answers are wrong, please lemme know x)
    Last edited by Alroundeath; 06-30-2010 at 05:33 AM.

  2. #2
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    << and >> are also bitwise operators(shift left and shift right), look those up on google if you want to know more about em ^^
    Ah we-a blaze the fyah, make it bun dem!

  3. #3
    Alroundeath's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    331
    Reputation
    8
    Thanks
    29
    My Mood
    Amused
    Quote Originally Posted by Hell_Demon View Post
    << and >> are also bitwise operators(shift left and shift right), look those up on google if you want to know more about em ^^
    Hopefully it shows it later on on this book x)

  4. #4
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    oh really nice to see that you are not going super fast and actually trying to get something on your head :P seriously keep going.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  5. The Following User Says Thank You to 'Bruno For This Useful Post:

    Alroundeath (06-30-2010)

  6. #5
    Crash's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    JAville
    Posts
    2,881
    Reputation
    163
    Thanks
    3,291
    My Mood
    Sleepy
    For number 2/3 it would be a function not really a source.(I could have misinterpreted what you mean though)

  7. #6
    Alroundeath's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    331
    Reputation
    8
    Thanks
    29
    My Mood
    Amused
    Quote Originally Posted by Sealionone View Post
    For number 2/3 it would be a function not really a source.(I could have misinterpreted what you mean though)
    Thanks x) I'll change it

  8. #7
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by Alroundeath View Post


    Thanks x) I'll change it
    what he said is not that right.. you are going to get confused, because main isnt just a function... and it doesnt need to be int main(), it can be void main(), and you dont need to return 0 on a funcion you can return almost anything.

    Code:
    double getResult(double num1, double num2)
    {
         return num1 + num2;
    }
    this is a function and as you can see... not nearly the same as int main() and return 0...

    edit: just keep reading your book and you will understand, don't try to understand that yet and dont get confused
    Last edited by 'Bruno; 06-30-2010 at 05:39 AM.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  9. #8
    Alroundeath's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    331
    Reputation
    8
    Thanks
    29
    My Mood
    Amused
    Quote Originally Posted by Brinuz View Post
    what he said is not that right.. you are going to get confused, because main isnt just a function... and it doesnt need to be int main(), it can be void main(), and you dont need to return 0 on a funcion you can return almost anything.

    Code:
    double getResult(double num1, double num2)
    {
         return num1 + num2;
    }
    this is a function and as you can see... not nearly the same as int main() and return 0...

    edit: just keep reading your book and you will understand, don't try to understand that yet and dont get confused

    o.o.................. /

    Currently looking at control statements.

    After I finish this chapter, I'll note everything in the chapter and add it to this thread x)

  10. #9
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by Alroundeath View Post



    o.o.................. /

    Currently looking at control statements.

    After I finish this chapter, I'll note everything in the chapter and add it to this thread x)
    just "forget" it... and go on good luck
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  11. #10
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    I'm kinda a noob at C++, so don't flame me too hard, but I thought that the "return" statement was to return a value to be used later on?

    Like If you had this:

    Code:
    int main(int num1 = 54)
    {
    return num1;
    }
    
    int main2()
    {
    cout << main << endl;
    return 0;
    }
    It would show "54" in the console...

  12. #11
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by lolland View Post
    I'm kinda a noob at C++, so don't flame me too hard, but I thought that the "return" statement was to return a value to be used later on?

    Like If you had this:

    Code:
    int main(int num1 = 54)
    {
    return num1;
    }
    
    int main2()
    {
    cout << main << endl;
    return 0;
    }
    It would show "54" in the console...
    yes and no... because as soon as main() ends, the program ends. And also from what i remember you cant attribute num1 with 54 at the function param.

    but yes you return a value to be used later, but not with main(), return 0 means that the program exited without problems (i think), and to actually end the program.

    but if you use:

    Code:
    int getNum()
    {
        return 1337;
    }
    
    int main()
    {
        int num = getNum();
        cout << num << endl;
        return 0;
    }
    that yes, its valid

    Output:

    Code:
    1337
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  13. The Following User Says Thank You to 'Bruno For This Useful Post:

    Hell_Demon (06-30-2010)

  14. #12
    Alroundeath's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    331
    Reputation
    8
    Thanks
    29
    My Mood
    Amused
    Quote Originally Posted by lolland View Post
    I'm kinda a noob at C++, so don't flame me too hard, but I thought that the "return" statement was to return a value to be used later on?

    Like If you had this:

    Code:
    int main(int num1 = 54)
    {
    return num1;
    }
    
    int main2()
    {
    cout << main << endl;
    return 0;
    }
    It would show "54" in the console...
    So far what I've learned is that 0 is false, and 1 is true. So the return is false, so it would not
    return. This is just a guess, but if the statement was return 1; it would return and enter 54 in
    the console.

    I'll check that right quick.

    Edit: I read earlier in the book, and there's different codes for the exiting of the program

    return 0; means the program exited successfully and without any errors.

    Last edited by Alroundeath; 06-30-2010 at 06:31 AM.

  15. #13
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by Alroundeath View Post


    return 0; means the program exited successfully and without any errors.

    just like i said in the post before yours
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

Similar Threads

  1. Temptation [random brush test]
    By taken4time in forum Showroom
    Replies: 12
    Last Post: 04-12-2010, 05:50 AM
  2. Random Shit
    By Dave84311 in forum General
    Replies: 15
    Last Post: 09-22-2007, 06:58 PM
  3. GBWC Bot Testing
    By Super-Man in forum GunBound Hacks / Bots
    Replies: 15
    Last Post: 02-05-2006, 10:58 PM
  4. Crappy Test
    By Kyojiro in forum Art & Graphic Design
    Replies: 8
    Last Post: 01-02-2006, 08:16 PM
  5. Test
    By kyo in forum Art & Graphic Design
    Replies: 49
    Last Post: 12-31-2005, 10:05 AM