C++ PROGRAMMING LMS MINDTAP
8th Edition
ISBN: 9781337696173
Author: Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 2, Problem 3PE
Program Plan Intro
Implementation of a program with typical sections
Program Plan:
Write a C++ program with a main function and the required set of statements to accomplish the following:
Write a C++ statement that includes the header file iostream
Write a C++ statement that allows you to use cin, cout, and endl without the prefix std::.
Write C++ statement(s) that declare the following variables: num1, num2, num3, and average of type int.
Write C++ statements that store 125 into num1, 28 into num2, and -25 into num3
Write a C++ statement that stores the average of num1, num2, and num3 into average
Write C++ statement(s) that output the values of num1, num2, num3, and average
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
in c++
Write a program to generate a random number between 1 - 100, and then display which quartile the number falls in.
First quartile is 1 - 25
Second quartile is 26 - 50
Third quartile is 51 - 75
Fourth quartile is 76 - 100
To generate a random number, follow these steps:
include necessary header files
#include <cstdlib> //for random functions
#include <ctime> //for time functions
set constants for the minimum and maximum values of the desired range
const int MIN_VALUE = 1; //minimum range value
const int MAX_VALUE = 100; //maximum range value
seed the random number generator (RNG) with a unique unsigned int value - system time!
unsigned seed = time(0); //system time in seconds since 1/1/1970
srand(seed); //seed the RNG
get a random number in the desired range
int num = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE;
The program should:
contain header comments as shown in class
display a "hello" message (more descriptive than shown in sample)…
In C++, int variables can be used to store the value of a logical expression
True
O False
in c++ add the request for the month number and read it in, add the request for the year and read it in, Ask what format the user would like to see the date in and write the if statement that will use the value in (format variable) to print out the date in the correct format. */
#include <iostream>
using namespace std;
int main() {
short day, month, year, format;
// Request day of the month (as a number) and put in day variable
cout << "Enter a day of the month (1, 12, 30, etc): ";
cin >> day;
cout << "Formats are (1) YYYY/MM/DD, (2) DD/MM/YYYY, and (3) MM/DD/YYYY" << endl;
cout << "Enter the number for the format you want (1, 2, or 3): ";
cin >> format;
}
Chapter 2 Solutions
C++ PROGRAMMING LMS MINDTAP
Ch. 2 - 1. Mark the following statements as true or...Ch. 2 - Prob. 2MCCh. 2 - Which of the following is not a reserved word in...Ch. 2 - Prob. 4SACh. 2 - 5. Are the identifiers quizNo1 and quiznol the...Ch. 2 - 6. Evaluate the following expressions. (3,...Ch. 2 - If int x = 10;, int y = 7;, double z = 4.5;, and...Ch. 2 - Prob. 8CPCh. 2 - 9. Suppose that x, y, z, and w are int variables....Ch. 2 - Prob. 10SA
Ch. 2 - Which of the following are valid C++ assignment...Ch. 2 - Write C++ statements that accomplish the...Ch. 2 - Write each of the following as a C++ expression....Ch. 2 - Prob. 14SACh. 2 - Suppose x, y, and z are int variables and wandt...Ch. 2 - 16. Suppose x, y, and z are int variables and x =...Ch. 2 - Suppose a and b are int variables, c is a double...Ch. 2 - 18. Write C++ statements that accomplish the...Ch. 2 - Which of the following are correct C++ statements?...Ch. 2 - Give meaningful identifiers for the following...Ch. 2 - 21. Write C++ statements to do the following....Ch. 2 - Prob. 22SACh. 2 - The following program has syntax errors. Correct...Ch. 2 - Prob. 24SACh. 2 - Prob. 25SACh. 2 - Preprocessor directives begin with which of the...Ch. 2 - 27. Write equivalent compound statements if...Ch. 2 - 28. Write the following compound statements as...Ch. 2 - 29. Suppose a, b, and c are int variables and a =...Ch. 2 - Suppose a, b, and sum are int variables and c is a...Ch. 2 - Prob. 31SACh. 2 - Prob. 32SACh. 2 - Prob. 33SACh. 2 - Prob. 34SACh. 2 - 1. Write a program that produces the following...Ch. 2 - Prob. 2PECh. 2 - Prob. 3PECh. 2 - 4. Repeat Programming Exercise 3 by declaring...Ch. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - 7. Write a program that prompts the user to input...Ch. 2 - Prob. 8PECh. 2 - 9. Write a program that prompts the user to enter...Ch. 2 - 10. Write a program that prompts the user to input...Ch. 2 - 11. Write a program that prompts the capacity, in...Ch. 2 - 12. Write a C++ program that prompts the user to...Ch. 2 - 13. To make a profit, a local store marks up the...Ch. 2 - 14. (Hard drive storage capacity) If you buy a 40...Ch. 2 - 15. Write a program to implement and test the...Ch. 2 - 16. A milk carton can hold 3.78 liters of milk....Ch. 2 - 17. Redo Programming Exercise 16 so that the user...Ch. 2 - Prob. 18PECh. 2 - 19. Write a program that prompts the user to input...Ch. 2 - 20. For each used car a salesperson sells, the...Ch. 2 - 21. Newton's law states that the force, , between...Ch. 2 - 22. One metric ton is approximately 2,205 pounds....Ch. 2 - 23. Cindy uses the services of a brokerage firm to...Ch. 2 - 24. A piece of wire is to be bent in the form of a...Ch. 2 - 25. Repeat Programming Exercise 24, but the wire...Ch. 2 - 26. A room has one door, two windows, and a...Ch. 2 - Prob. 27PECh. 2 - 28. In an elementary school, a mixture of equal...Ch. 2 - 29. A contractor orders, say, 30 cubic yards of...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Computer graphicsarrow_forwardC++arrow_forward#include <stdio.h>#include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start:// You are given a partially complete program. Complete the functions in order for this program to work successfully.// All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters.// You can assume that all inputs are valid. Ex: If prompted for an integer, the user will input an integer.// You can use only the strlen() of strings.h library to check string length. Do not use any other string functions // because you are supposed to use pointers for this homework. // **** DO NOT use arrays to store or to index the characters in the string **** // Global Macro Values. They are used to define the size of 2D array of characters#define NUM_STRINGS 4#define STRING_LENGTH 50 // Forward Declarationsvoid…arrow_forward
- 1. The C++ statement num = 1; compares the contents of the num variable to the number 1. Group of answer choices True False 2. The user can interactively terminate a program loop through the use of a Group of answer choices semicolon scope resolution operator sentinel value kryptonite 3. A do-while statement Group of answer choices automatically performs a validity check on data will always execute at least on time None may never executearrow_forwardTo use the string manipulation functions, which header file must be included in a C++ application?arrow_forwardExercise 5: Please perform in C++ Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+,-, *, or /) and input the numbers. ● ● ● Furthermore, your program must consist of the following functions: Function showChoice(): This function shows the options to the user and explains how to enter data. Function add(): This function accepts two numbers as arguments and returns the O O O O Function subtract(): This function accepts two numbers as arguments and returns their difference. O Function multiply(): This function accepts two numbers as arguments and returns the product. Function divide(): This function accepts two numbers as arguments and returns the quotient. sum.arrow_forward
- For C++ Code Template: //Include statements#include <iostream>#include <string> using namespace std; //Global declarations: Constants and type definitions only -- no variables //Function prototypes int main(){ //In cout statement below substitute your name cout << "Your name" << endl << endl; //Variable declarations //Program logic //Closing program statements system("pause"); return 0;} //Function definitionsarrow_forwardC++arrow_forwardPJ 6 – Super Calculator Please write a C++ program that can perform the following 6 valid operators for 2 numbers: N1 and N2. You need to prompt the user to enter a number, an operator, and another number. To simplify your program, please declare N1, N2, and result as double-floating numbers, and operator as char. Please see the sample test below to design your application program properly. This program is a super calculator for users to enjoy. Your program must continue asking for inputs from the user. If the user enters @' as the operator, you must thank the user and then exit the program immediately. As you can see, PJ 6 is to add some more user- friendly features to the Project 5 (PJ 5) - Simple Calculator. The O valid operators for this super calculator are as follows: 1. + for addition of N1 and N2. Therefore, result = (N1 + N2). 2. - for subtraction of N2 from N1. Therefore, result = (N1 – N2). 3. * for multiplication of N1 with N2. Therefore, result = (N1 * N2). for…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education