COSC175 Variables Lab Introduction to Variables

COSC175 Variables Lab Introduction to Variables

<p>COSC175 Variables Lab – Introduction to variables </p><p>Type in Word. Work with a partner and submit ONE COPY per pair. Include the following at the top of your submission:</p><p>Partner 1: Name ______</p><p> role (driver or navigator) ______</p><p>Partner 2: Name ______</p><p> role (driver or navigator)______</p><p>Please note if one partner did not work on all problems.</p><p>1. Read Ch. 3. Using the C++ editor, type the following program: #include <iostream> #include <string> using namespace std; int main () { //declarations string name;</p><p>//input cout <<"Enter your first name" << endl; cin >> name;</p><p>//output cout << "Hello " << name << "! " << endl;</p><p> return 0; } 2. Compile and run. What does the cin statement do? 3. What does the cout statement do? 4. Is name a variable or a constant? 5. What type is name? 6. Add the following line to the declaration statements: int age; Add the following lines to your program: cout << “Enter your age” << endl; cin >> age; Compile and Run. What type is age? Describe this type. 7. Add a line to print the age to the screen. Compile and Run. 8. Add the following line to the declaration statements: float bodyTemp; Add the lines to input and out your body temperature. Compile and run. What type is bodyTemp? Describe this type. 9. Add the appropriate declaration, input and output statement for each of the following: Height (hint, use two variables) Weight Sex (hint, use the char type) Last name</p><p>10. Turn in: 1. The final program 2. The final output Answers to these questions only: 3. What is the integer data type and how is it declared in C++? 4. Give an example of where the integer type might be used. 5. What is the real data type and how is it declared in C++? 6. Give an example of where the real type might be used. 7. What is the string data type and how is a string declared in C++? 8. Give an example of where the string type might be used. 9. What is the boolean type and how is an boolean declared in C++? 10. Give an example of where the boolean type might be used.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us