C++ Introduction - Learn Cisco

Post Top Ad

C++ Introduction

Maggie, complete the following tasks. Good luck.

Exercise 1
Write a code that displays two lines in the command window and the trailing new line. Compile and run it to test it. The result should be similar to mine presented below; make sure the cursor start at new line).



Extra Credit
  1. What is the structure of the C++ program required to properly compile and run?
  2. What is the statement that displays a text on a screen (text = string)?
  3. What do you need to include in the code to display the string on a screen?
  4. What character do you use to end a statement in C++?
Hint
http://www.cplusplus.com/doc/tutorial/program_structure/

Exercise 2
Write a code that asks a user for two integer numbers. The numbers should be multiplied and result displayed (look at the example below). The program should ask the user if she/he wants to do it again.



Extra Credit
  1. What is the difference between do-loop and do-while-loop?
  2. What third type of loop do you know and in which situation would you prefer to use it rather than while-loop?
  3. What type of variable did you use to store user's answer to the question after showing the result?
  4. What other types of variables are used in C++?
  5. Can you tell the characters used for addition, subtraction, multiplication, division?
Hint
http://www.cplusplus.com/doc/tutorial/variables/

Post Top Ad