| View previous topic :: View next topic |
| Author |
Message |
Qvazzler Advanced Cheater
Reputation: 0
Joined: 02 Jan 2007 Posts: 68
|
Posted: Sat Oct 20, 2007 12:09 pm Post subject: C++ Test 1: Basics |
|
|
Hope you guys don't mind showing off your skills. This is in fact a real test made by my C++ teacher, so there are no fail-questions here.
1. What extension should you use on a sourcefile for C++?
2. Write two simple ways to perform a linebreak in C++
3. Which of the following is the correct way to read an input value to a variable?
variable << cin;
cin > variable;
cin >> variable;
cin(variable);
cin << variable;
4. Which of the following is a condition that checks if a variable's value is between 40 and 80?
if(val >= 40 || val <= 80)
if(val > 40 && val < 80)
if(val >= 40 && <= 80)
if(val >= 40 && val <= 80)
5. Which of these statements are correct? (There are more answers than 1)
Java and C#'s syntaxes look slightly alike
C++ programs can only be compiled in windows
You don't have to compile in order to run a C++ program
Programs in C++ don't crash
C++ came after C.
A C++ program doesn't need a main method
6. Which are the two correct ways to comment in C++?
/* a comment */
//a comment
>> a comment
'a comment
--a comment
<< a comment
7. Which two characters are used to make a 'codeblock'?
8. What sign is used to end a line of code? |
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Sat Oct 20, 2007 1:05 pm Post subject: |
|
|
| Ahahahahahahaha. |
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Sat Oct 20, 2007 1:41 pm Post subject: |
|
|
| Nice.. Though it's for people who learned C++ for only about a day.. And even less.. |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sat Oct 20, 2007 2:03 pm Post subject: Re: C++ Test 1: Basics |
|
|
| Qvazzler wrote: | 3. Which of the following is the correct way to read an input value to a variable?[/b]
variable << cin;
cin > variable;
cin >> variable;
cin(variable);
cin << variable; | NONE!
| Code: | | std::cin >> variable; |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sat Oct 20, 2007 7:14 pm Post subject: Re: C++ Test 1: Basics |
|
|
| Qvazzler wrote: | Hope you guys don't mind doing my homework.  |
|
|
| Back to top |
|
 |
SF I'm a spammer
Reputation: 119
Joined: 19 Mar 2007 Posts: 6028
|
Posted: Sat Oct 20, 2007 9:29 pm Post subject: Re: C++ Test 1: Basics |
|
|
| Jani wrote: | | Qvazzler wrote: | 3. Which of the following is the correct way to read an input value to a variable?[/b]
variable << cin;
cin > variable;
cin >> variable;
cin(variable);
cin << variable; | NONE!
| Code: | | std::cin >> variable; |
|
You don't have to include the "std::"
I'm assuming his teacher has it at the top of the code _________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sat Oct 20, 2007 10:49 pm Post subject: Re: C++ Test 1: Basics |
|
|
| SaviourFamily wrote: | | You don't have to include the "std::" |
Actually, you do.
| SaviourFamily wrote: | | I'm assuming his teacher has it at the top of the code |
Do you mean dumping the contents of std into the current namespace? That's foolish, and any teacher that teaches this to students before teaching them what namespaces are and what their purpose is should be burned at the stake. People also use void for main, it doesn't mean you should assume everyone does. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Oct 21, 2007 12:22 am Post subject: |
|
|
1. .cpp
2. "\n\r" and "endl"
3. cin >> variable;
4. if(val > 40 && val < 80)
5. "C++ came after C." The rest are either wrong or opinions, not statements.
6. "/* a comment */" and "//a comment"
7. { and }
8. ;
| appalsap wrote: | | SaviourFamily wrote: | | You don't have to include the "std::" |
Actually, you do. |
No, you don't. As you said yourself, namespaces handle this for you. (using namespace std;) All depending on if his teacher has shown them what it is and what it does. |
|
| Back to top |
|
 |
Qvazzler Advanced Cheater
Reputation: 0
Joined: 02 Jan 2007 Posts: 68
|
Posted: Sun Oct 21, 2007 4:55 am Post subject: |
|
|
I meant to post last night but the forum was overloaded (or perhaps it was my internet connection?), and I can admit it was a mistake putting up these questions.
I aced this test when it was given to me, so I guess if I can do it, the whole lot of you can aswell.
Also when it comes to teaching kids who don't know programming for shit, it might be a good idea to ignore some fundamentals until they at least know how to make a "Hello World" app, if you know what I mean. I wasn't taught what namespaces do or <iostream> (although that one was kinda obvious) was at first, but I do now, and it wasn't really that hard to learn. But hey, if you're a teacher, try teaching 15 halfly unmotivated kids the bible of programming..
Edit: Making a new topic on more advanced stuff, note that I've already aced this one aswell (except for 1 lousy mistake as usual ), feel free to flame inside it too.  |
|
| Back to top |
|
 |
|