Concept explainers
Implementation of a
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
Trending nowThis is a popular solution!
Chapter 2 Solutions
C++ Programming: From Problem Analysis to Program Design
- Consider the following C++ code and fill the blanks: string name, phrase; cout<<“Please enter your full name:” <<endl; cin>>name; //What is your input? ___ ________________________ phrase = “ loves holidays!” phrase = name + phrase; cout<<phrase<<endl;arrow_forwardThis is for Python Programing version 3.8.5 - Need a program that uses a text file to store weekly payroll data for the office. The program should enable the user to enter the name, hourly pay rate, and weekly hours for a number of office employees. The pay rate and hours should be type float, and each datum should be written to its own line in the file. Enter data for at least five employees and then close the file. Please include Pseudocode and def main () function.arrow_forward*Correct all syntax errors so that the C++ program will compile correctly.* Procided C++ code: #include<iostream>#include<conio.h> Standard namespace declarationusing namespace std; Main Functionint main(){ double myMoney = 1000.50; //this should be printed out Standard Ouput Statement cout"Please be sure to correct all syntax errors in this program"<<endl; cout<<"I have corrected all errors for this program. <<endl; cout<<" The total amount of money available is = "<< <<endl; // Wait For Output Screen Main Function return Statement return 0;} Thank you for your helparrow_forward
- 9. What will be the output of the following C++ code? #include <iostream> using namespace std; enum cat { temp = 7 }; int main() { int age = 14; age /= temp; cout << "If you were cat, you would be " << age << endl; return 0; }arrow_forwardWrite a main function that calls div (int x, int y); Write the code below. Use C++ programming language.arrow_forward(Numerical) a. Write a C++ program that accepts an integer argument and determines whether the passed integer is even or odd. (Hint: Use the % operator.) b. Enter, compile, and run the program written for Exercise 8a.arrow_forward
- Use Dev C++ The Problem: Topics: Switch statement, Loops, Functions, Creating Program-Defined Value-Returning Functions, Calling a Function, Void Functions Write a program in C++ involving a Switch statement from the 4 program given below : 1. Create a Program that allows the user to have a switch statement menu from your following BOM and Info. (5 Materials per BOM) Use 12% as your tax for Manufacturing and Construction BOMs. (VAT Registered) Use 3% as your tax for Electrical BOMs. (Example as Non-VAT Registered) Program Requirement: 1. The program should compute for the : Total added tax Net total Amount = Amount without tax Gross total amount = Amount with tax 2. Quantity should be asked for every material given. 3. Create an IPO chart and Desk CheckingCompany name Date : LastName, FirstName, M.I. LastName, FirstName, M.I. LastName, FirstName, M.I. 4. The program should use both VR Functions and Void Functions for the 3 BOMs.arrow_forwardConsider the following main function. The blank line represents a line of code that is missing. #include <string> #include <iostream> using namespace std; int main() { _______________________ } Write a C++ statement to create a variable called last that can store an employee last name.arrow_forwardQ1) How to use C code to write a C program segment to prompt a user for entering an integer and save it into an “option”variable. In your program, you have to make sure the value (option) entered by the user is either1, 2 or 3 only. Otherwise, display a message asking the user to re-enter the “option” value.[Note: Assume that all the necessary variables have been declared]arrow_forward
- Find errors in the following lines of c++ code assuming included header files. Write correct form with line number. 1. int main() 2. { 3. Int a=4.5 4. Char ch=’a’ 5. Int a++; 6. Cout<<”the value of a=’; 7. Cout>>a; 8. For( ; a<=5; ) 9. Cout<<a; 10. }arrow_forwardThis question has three parts a. Write a C function called stringCopy(destination, source). This function takes two C strings as parameters and copies the source string into the destination string. Once the copy is completed, the function returns the number of characters (except null) that were copied. You cannot use the C library functions strcpy, strcat or any of their variants. You need to write all the code required to do the copy yourself. However, you may use a C library function to determine the length of a string. b. What is the important precondition for stringCopy to work? Explain why the precondition is necessary. c. Write a C main program to demonstrate/test that your stringCopy function works. You will need the program to read user input into the source string.arrow_forwardModule/Week 3 ASSIGNMENT (CONTROL STRUCTURES . IF ..ELSE)Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file. You must also display the floating-point result up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space. In addition, you must print to the console “Excellent” if the grade is greater than or equal to 90, “Well Done” if the grade is less than 90 and greater than or equal to 80, “Good” if the grade is less than 80 and greater than or equal to 70, “Need Improvement” if the grade is less than 70 and greater than or equal to 60, and “Fail” if the grade is less than 60. Submit C++ Programming Assignment 3 by 11:59 p.m. (ET) on Monday of Module/Week 3.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr