Starting Out With C++ From Control Structures Through Objects, Student Value Edition (8th Edition)
Starting Out With C++ From Control Structures Through Objects, Student Value Edition (8th Edition)
8th Edition
ISBN: 9780133778816
Author: Tony Gaddis
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 3.2, Problem 3.9CP

Explanation of Solution

Given Program:

//Include the required header files

#include <iostream>

#include <cmath>

using namespace std;

//Main Function

int main()

{

//Declare the variables

double value1, value2, value3;

//Print the statement

cout << "Enter a number: ";

//Get a value from the user

cin >> value1;

//compute and store it in a variable

value2 = 2 * pow(value1, 2.0);

//compute and store it in a variable

value3 = 3 + value2 / 2 - 1;

//Print the result

cout << value3 << endl;

//Return the statement

return 0;

}

Explanation:

  • Include the required header files.
  • Give the “main ()” function.
    • Declare the required variables.
    • Get a value from the user and store it in a variable “value1”.
    • Find the power value (value1^2.0), multiply it by 2 and store it in a variable “value2”.
    • Do the divide operation and add the result with 3 and finally store it in a variable “value3”.
    • Print the value on the screen.
If the user enters The program will display Explanation
2 6

value1 = 2

value2 = 2 * (22...

Blurred answer
Students have asked these similar questions
ANSWER IN C PROGRAM- Consider the following structure definition and solve the following problems- typedef struct {int phoneID; // unique ID will start from 1 up to N.char phoneName[50];int price;int ramMemory;float cpuSpeed;int gpuMemory;char userName[50];int userPhoneNo;char userCountry[50];} SmartPhoneType; 1. Write a function that will print all the information of a specific smart phone. Use the prototype -void printPhoneInfo(SmartPhoneType phoneType);
This exercise assesses the skills required to develop user defined functions, and pointers. Exercise 2Write a C++ program to develop a Vehicle Fine Management System for Police. The program will have the following features.1. A user defined function called “Student Registration”. This function prompts a user to enter a student’s personal data i.e., Student Number, Student Name, Age and City and stores them. 2. A user defined function called “Module Enrolment”. This function takes student number from themain function as an argument and prompts a user to enter student two modules details i.e. Module name, Module Code and Module Credits Hours (15 or 30) and stores them. The programs should display an error message if a user enters credit hour other than 15 or 30. 3. A user defined function called “Student Assessment”. This function takes student number from the main function as an argument and prompts a user to enter Module 1 and Module 2 marks and storesthem. 4. A user defined function…
ANSWER IN C PROGRAM- Consider the following structure definition and solve the following problems- typedef struct {int phoneID; // unique ID will start from 1 up to N.char phoneName[50];int price;int ramMemory;float cpuSpeed;int gpuMemory;char userName[50];int userPhoneNo;char userCountry[50];} SmartPhoneType; Question 2 says : to write a function that will print the information of a specific smart phone using the prototype: void printPhoneInfo(SmartPhoneType phoneType) 1. Print all the information of the phone using the function mentioned in the 'Question 2' which hasthe highest price. Use the prototype -void getHighestPricePhone ( SmartPhoneType mobileList[], int size, SmartPhoneType*highestPricePhone);

Chapter 3 Solutions

Starting Out With C++ From Control Structures Through Objects, Student Value Edition (8th Edition)

Ch. 3.5 - Assume the following variable definitions: int a =...Ch. 3.5 - Complete the following program skeleton so it asks...Ch. 3.5 - Prob. 3.13CPCh. 3.6 - Write a multiple assignment statement that assigns...Ch. 3.6 - Write statements using combined assignment...Ch. 3.6 - Prob. 3.16CPCh. 3.7 - Write cout statements with stream manipulators...Ch. 3.7 - Prob. 3.18CPCh. 3.7 - The following program skeleton asks for an angle...Ch. 3.9 - Prob. 3.20CPCh. 3.9 - Assume the variables angle1 and angle2 hold angles...Ch. 3.9 - To find the cube root (the third root) of a...Ch. 3.9 - The cosecant of the angle a is 1sina Write a...Ch. 3 - Assume the following variables are defined: int...Ch. 3 - Prob. 2RQECh. 3 - Prob. 3RQECh. 3 - Complete the following table by determining the...Ch. 3 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Assume a program has the following variable...Ch. 3 - Assume qty and salesReps are both integers. Use a...Ch. 3 - Rewrite the following variable definition so that...Ch. 3 - Complete the following table by providing...Ch. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a cout statement so the variable divSales is...Ch. 3 - Write a cout statement so the variable totalAge is...Ch. 3 - Prob. 14RQECh. 3 - The__________ library function returns the cosine...Ch. 3 - The ___________ library function returns the sine...Ch. 3 - The ________ library function returns the tangent...Ch. 3 - The __________ library function returns the...Ch. 3 - The _________ library functionreturns the...Ch. 3 - The _________ library function returns the natural...Ch. 3 - Prob. 21RQECh. 3 - The _______ library function returns the value of...Ch. 3 - The _________ libraryfunction returns the square...Ch. 3 - The ________ file must beincluded in aprogramthat...Ch. 3 - A retail store grants its customers a maximum...Ch. 3 - Write a pseudocode algorithm for a program that...Ch. 3 - Write a pseudocode algorithm for a program that...Ch. 3 - using namespace std; int main () { double number1,...Ch. 3 - #include iostream using namespace std; int main()...Ch. 3 - #include iostream; using namespace std; int main()...Ch. 3 - #include iostream; using namespace std; main { int...Ch. 3 - #inc1ude iostream; using namespace std; main {...Ch. 3 - #inc1ude iostream; using namespace std; int main()...Ch. 3 - What will each of the following programs display?...Ch. 3 - #include iostream using namespace std; int main()...Ch. 3 - (Assume the user enters George Washington.)...Ch. 3 - (Assume the user enters 36720152. Use a...Ch. 3 - Miles per Gallon Write a program that calculates a...Ch. 3 - Stadium Seating There are three seating categories...Ch. 3 - Test Average Write a program that asks for five...Ch. 3 - Average Rainfall Write a program that calculates...Ch. 3 - Ingredient Adjuster A cookie recipe calls for the...Ch. 3 - Box Office A movie theater only keeps a percentage...Ch. 3 - How Many Widgets? The Yukon Widget Company...Ch. 3 - How Many Calories? A bag of cookies holds 30...Ch. 3 - How Much Insurance? Many financial experts advise...Ch. 3 - Automobile Costs Write a program that asks the...Ch. 3 - Celsius to Fahrenheit Write a program that...Ch. 3 - Currency Write a program that will convert U.S....Ch. 3 - Monthly Sales Tax A retail company must file a...Ch. 3 - Property Tax A county collects property taxes on...Ch. 3 - Senior Citizen Property Tax Madison County...Ch. 3 - Math Tutor Write a program that can be used as a...Ch. 3 - Interest Earned Assuming there are no deposits...Ch. 3 - Monthly Payments The monthly payment on a loan may...Ch. 3 - Pizza Pi Joes Pizza Palace needs a program to...Ch. 3 - Angle Calculator Write a program that asks the...Ch. 3 - Stock Transaction Program Last month Joe purchased...Ch. 3 - Word Game Write a program that plays a word game...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education