C++ Coding Basics Word Scramble
|
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Question | Answer |
What function must every program have in C++? | int main() {...} |
How do you denote a comment in C++? Also multi-line comments? | // A Comment: also an OS-independent newline. /* ... */ Denotes a multi-line comment. |
How should you create C++ source code files? With what extension does the file have? | C++ source code files should be created with a text editor and have the extension .cpp |
In Windows, the GNU C++ compiler is called DJGPP; How do you compile and run the source code titled hello.cpp from an MS-DOS box? | gxx hello.cpp -o hello.exe >>>hello |
How do you compile and run hello.cpp in the UNIX shell window? | g++ hello.cpp -o hello -Wall -O ./hello |
What function does -o hello serve? | -o renames the default a.out executable. In Windows the default is A.EXE |
What function does -Wall serve? | -Wall turns on all warnings. |
What function does -O serve? | -O optimizes (compiles slower but runs faster) |
How do you use the network or GUI interface in UNIX? | You must use the X and socket libraries. |
How do you use the network or GUI interface in Windows? | You must use the Windows API and a compiler that supports them; such as, from Microsoft. GUI/network programming is nonportable. |
Where can you find links to free and commercial C++ compilers? | Visit cplusplus (dot) com for links. |
A program is a collection of what three elements? | A program is a collection of functions, and type and object declarations. |
s; | Expression or declaration |
; | Empty statement |
{s; s;} | A block or 0 or more statements is a statement |
if (t) s; | If t is true then s |
if (t) s; else s; | else is optional |
while (t) s; | Loop 0 or more times |
for (s1; t; s2) s; | s1; while (t) (s; s2;) |
break; | Jump from while, for, do, switch |
return x; | Return x to calling function |
try {throw x;} | Throw exception, abort if not caught, x has any type |
catch (T y) {s;} catch (...) {s;} | if x has type T then y=x, jump to s else jump here (optional) |
do s; while (t); | (uncommon) s; while (t) s; |
continue; | (uncommon) Start next loop of while, for, do |
switch (i) { case C: s; break; default: s; } | if (i==C) go here optional, else go here |
label: goto label; | (rare) Jump to label within a function |
Give a declaration example: | int a[10], i=0, j; |
Give a expression example: | a[i+2]=3; |
Declarations are destroyed at the end of a block {s; s;} (True/False)? | Declarations like a, i, j; and expressions like a[i+2]=3 are destroyed at end of block {s; s;}. |
18 levels of operator precedence: 1 | X::m Member m of namespace or class X ::m Global name m when otherwise hidden by a local declaration |
18 levels of operator precedence: 2 | p[i] i'th element of container p x.m Member m of object x p->m Member m of object pointed to by p f(x,y) Call function f() i++ i-- static_cast<T>(x) |
18 levels of operator precedence: 3 | *p &x -a !i (T)x new T delete p ++i --i sizeof x |
18 levels of operator precedence: 4 | x.*p (rare) q->*p (rare) |
18 levels of operator precedence: 5 | a*b a/b i%p |
18 levels of operator precedence: 6 | a+b a-b |
18 levels of operator precedence: 7 | x<<y x>>y |
18 levels of operator precedence: 8 | x<y x>y x<=y x>=y |
18 levels of operator precedence: 9 | x==y x!=y |
18 levels of operator precedence: 10 | i&j AND |
18 levels of operator precedence: 11 | i^j XOR |
18 levels of operator precedence: 12 | x|j OR |
18 levels of operator precedence: 13 | i&&j i AND THEN j only if i is TRUE |
18 levels of operator precedence: 14 | i||j i OR ELSE j only if i is FALSE |
18 levels of operator precedence: 15 | x=y x+=y |
18 levels of operator precedence: 16 | i?x:y If i is TRUE then x ELSE y |
18 levels of operator precedence: 17 | throw x |
18 levels of operator precedence: 18 | x,y Evaluate x and y, RESULT is y |
Created by:
themagicdwarf
Popular Computers sets