Advanced struc prog with CH ELET 422-02 Due 02/13/2017 Chapter 2: Introduction to c++ Programming: Input/output and operator Section 2.2 First Program in c++: Printing a Line of Text line comments that should be ignored by the compiler are noted using: End of 1. 2.2 Q1: a. Two forward slashes b. Three forward slashes (/in. c. A slash and a star d. A slash and two stars 2.2 Q2: Which of the following does nor cause a syntax error to be reported by the C++ compiler? a. Mismatched b. Missing in a comment. c. Missing at the end of a statement d. Extra blank lines. 3. 2.2 Q3: Which of the following is not a syntax error? a std: cout Hello world std: cout Hello b, world c, std: :cout Hello world d. std: :cout Hello world! 4. 2.2 Q4: The escape sequence for a newline is: b. At c, Mr 2.2 Q5: Which of the following statements would display the phrase c++ is fun? a std: cout \"This is funArc++ std: :cout is fun std: :cout \\\"c++ is fun d. std: :cout C++ is fun: Section 2.3 Modifying our First C Program 2.3 Q: Which of the following is not a valid C++ identifier? a. my value b AAAl c, width 7. 2.3 Q2: Which is the output of the following statements? std: :cout Hello std: :cout world a. Hello world b, World Hello c, Hello world d world
1. answer is option (a) //
in C++, end-of-line comment is denoted by //, this is used for single line cooment
eg, // this is an example for singlr line cooment.
if it is a multiple line comment, it is denoted by /*
eg, /* this is an example for
multiple line */
2. answer is option d) Extra blank lines.
Putting extra blank lines are not an issue in C++. but mismatched { }, missing */ and missing of semi column will result in a syntax error.
3. answer is option c) std::cout << \"hello world ! \" ;
All other options have syntax error.because hello world is a string. string should be enclosed within \" (double quote )
4. answer is option a) \
5. answer is option c) std::cout << \"\\\"C++ is fun\\\"\" ;
******************* END ***************** PLS GIVE ME GOOD RATING *******************************