Chapter 3 Expressions and Interactivity

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

include the iostream file

3.1 What header file must be included in programs using cin ?

True

3.2 TRUE or FALSE: cin requires the user to press the [Enter] key when finished entering data

the answer is B

3.3 Assume value is an integer variable. If the user enters 3.14 in response to the following programming statement, what will be stored in value ? cin >> value; A) 3.14 B) 3 C) 0 D) Nothing. An error message is displayed.

//This program multiplies two number and sidplay the result #include<iostream> using namespace std; int main() { double first, second, product; cout << " Insert the first number: "; cin >> first, cout << " Insert the Secon number: "; cin >>second; product = first * second; cout << " The product is: "<< product; return 0; }

3.5 The following program will run, but the user will have difficulty understanding what to do. How would you improve the program? // This program multiplies two numbers and displays the result. #include <iostream> using namespace std; int main() { double first, second, product; cin >> first >> second; product = first * second; cout << product; return 0; }

// This program display the convertion // the pounds to kiklogram #include <iostream> using namespace std; int main() { double pounds, kilograms; cout << "Enter your weight in pounds: "; cin >> pounds; kilograms = pounds / 2.2; cout << "Your weight in kilograms is: "; cout << kilograms; cin >> kilograms; return 0; }

3.6 Complete the following program skeleton so it asks for the user's weight (in pounds) and displays the equivalent weight in kilograms. #include <iostream> using namespace std; int main() { double pounds, kilograms; // Write code here that prompts the user // to enter his or her weight and reads // the input into the pounds variable. // The following line does the conversion. kilograms = pounds / 2.2; // Write code here that displays the user's weight // in kilograms. return 0; }


Ensembles d'études connexes

Towards a New Worldview Chapter 16

View Set

Texas Real Estate Finance - Chp. 1 - The Nature and Cycle of Real Estate Finance

View Set

Life Insurance Final Exam Review

View Set

Chapter 16 Nervous System: Senses

View Set

Chapter 5 Nutrition For Healthy Living

View Set

Bulletin 5 - Substance abuse policy

View Set