C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 5, Problem 27SA
Explanation of Solution
Code comments have been added in the source code itself to have a better understanding of the code.
//include the required haeder file
#include <iostream>
using namespace std;
//definition of the main function
int main()
{
//declare the variable
int j;
//for loop will be executed until j<8
for (j = 0; j < 8; j++)
{
//print 0*25=0 along with -
cout << j * 25 << " - ";
...Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The process of integer division involves two positive integers, N and D, finding a non-negativeresult Q represents the quotient and R represents the remainder. Write a C++ program thatsuccessfully compiles and executes using g++ using the following flow chart. You mustscope the variables as indicated (even though global variables rot) as indicated, and must get thevalues for N and D from the user.Use gloabal variables, the point of this program is to show you that global variables are a lousy practice.
Look at the flowchart for more understanding.
Given an airplane’s acceleration ?? and take-off speed ??, you can compute the minimum runway ??????????ℎ needed for an airplane to take off using the following formula:
??2
??????????ℎ = 2??
Write a C++ program that prompts the user to enter ?? in meters/second (m/s) and the acceleration ?? 3in meters/second squared (m/s2) and displays the minimum runway length.
Ram, Mohan and Sohan took loan of Rs. x, y and z on rate of interest r%, p%, q% for time t1, t2 and t3 years respectively. Calculate simple interest they will pay and find who will pay the most using ternary operator? Write a C program for that.
Chapter 5 Solutions
C++ Programming: From Problem Analysis to Program Design
Ch. 5 - Prob. 1TFCh. 5 - What type of loop, such as counter control or...Ch. 5 - Prob. 20SACh. 5 - Prob. 27SACh. 5 - Prob. 40SACh. 5 - Prob. 45SACh. 5 - Write a program that prompts the user to input an...Ch. 5 - Write a program that prompts the user to input a...Ch. 5 - Write a program that uses while loops to perform...Ch. 5 - Redo Programming Exercise 8 using dowhile loops.
Knowledge Booster
Similar questions
- DO IT WITH C++ PROGRAM 1. Write a parameter and return program that will require the user to enter a temperature in Celsius and convert it to degree Fahrenheit and degree Formula: Fahrenheit = (9/5) * Celsius + 32 Kelvin = Celsius + 273 2. Refer to No. 1, transform the program using function header and function 3. Write a global and local variable program that would require the user to input a value of the Radius of a circle and then show the output in the diameter, circumference of the circle and area of the circle.arrow_forwardEmployees in a company receives net salary after the deductions for tax, Staff Provident Fund (SPF), and Global Insurance (GI): Basic Salary Range ($) Tax Rate SPF GI 0 – 1999 0 % 11 % 1 % 2000 – 2999 5 % 12 % 2 % 3000 – 4999 8 % 13 % 5 % Above 5000 10 % 17 % 8 % Based on the table given, you are required to write a C programming for a system that accepts the employee’s basic salary, and generates the net salary after the respective deductions as described abovearrow_forwardWrite a C statement to accomplish each of the following tasks.a) Define variables sum and x to be of type int.arrow_forward
- What does it mean by line1 of the following C++ statements. void y (int k) //line1 { if ((k%2)==0) cout<< k << " is an even number"; else cout<< k << " is an odd number"; } A.Function name y receives an int-type parameter. The function y does not return anything to the caller. B.Function name y receives an int-type parameter. The function y does return an int-type value to the caller.arrow_forwardThe process of integer division involves two positive integers, N and D, finding a non-negativeresult Q represents the quotient and R represents the remainder. Write a C or C++ program thatsuccessfully compiles and executes using gcc or g++ using the following flow chart. You mustscope the variables as indicated (even though global variables rot) as indicated, and must get thevalues for N and D from the user.Use gloabal variables, the point of this program is to show you that global variables are a lousy practice. Look at the flowchart for more understanding.arrow_forwardYou will get practice in this assignment in the following areas in C/C++:• Writing a simple C++ program• Compiling and linking• Logical expressions• Simple arithmetic and/or assignment statements• Standard Input and output• Variable Declaration• Simple If statements• Simple while statement• Declaring constants and variables• Good programming practices Programming Specifications:1. Your program must produce the minimal bill and coin count.2. Your program must accept values between 1 and 1,000,000 pennies. If a number is entered outside that range your program should continue to ask for a valid number.3. No Global Variables BUT your program must use global constants.4. You must use declared constants in your program and not literal values.5. Only print out non-zero values.. So, if there are no Five’s ….then don’t print zero fives. Design Considerations/Algorithms To see if you need to issue 100 dollar bills you divide the amount of pennies by the number of pennies in a 100 dollar bill.…arrow_forward
- Here's is my C++ program exercise 4-12: Suppose that billingAmount is a double variable, which denotes the amount you need to pay to the department store. If you pay the full amount, you get $10.00 or 1% of the billingAmount, whichever is smaller, as a credit on your next bill; If you pay at least 50% of the billingAmount, the penalty is 5% of the balance; If you pay at least 20% of the billingAmount and less than 50% of the billingAmount, the penalty is 10% of the balance; otherwise the penalty is 20% of the balance. Design an algorithm that prompts the user to enter the billing amount and the desired payment. The algorithm then calculates and outputs the credit or the remaining balance. If the amount is not paid in full, the algorithm should also output the penalty amount. Now here's what I have so far: #include <iostream>#include <iomanip> using namespace std; //declare constant variables //define the main functionint main(){//declare the variablesdouble…arrow_forwardWrite a C program that reads a double value (x) from the user and then uses it to compute the value of the mathematical constant e to the power of x (ex) and print it in main using the following infinite series: ex =1+x/1!+x2/2!+x3/3!+x4/4!+... Your program should include the following three functions: 1- function called powerOfNumber which takes two parameters: x (double) and y (integer) and returns the value of xy . Function PowerOfNumber MUST use a while loop. ( Not allowed to use the predefined function pow in math.h). 2- function called factorialOfNumber which takes one parameter x (integer) and returns its factorial. Function factoriaOfNumberl MUST use a for loop. 3- function called computeExpo which receives one parameter x (double) and returns the value of ex for the given x using the series above as well as functions powerOfNumber and factorialOfNumber ( 1 and 2 above) . Function computer_ex MUST use a do/while loop. The loop should stop 1 when the new term…arrow_forwardUsing the following description, please replace the return line in C code; /* * conditional: same as x ? y : z * Examples: * conditional(0,3,4) = 4 * conditional(1,3,4) = 3 * conditional(4,5,6) = 5 * conditional(-1,7,8) = 7 * Legal ops: ! ~ & ^ | + << >> * Max ops: 16 */ int conditional(int x, int y, int z) { return 2 } You cannot: 1. Use any control constructs such as if, do, while, for, switch, etc. 2. Define or use any macros. 3. Define any additional functions in this file. 4. Call any functions. 5. Use any other operations, such as &&, ||, -, or ?:, not listed in the the "Legal ops" list for the function. 6. Use any form of casting. 7. Use any data type other than int.arrow_forward
- Hi. Can you solve this question? Write a c program dist.c that calculates the distance between two points and prints the result on the screen. The cartesian coordinates of the points would be given in the command line as 6 parameters. Your program should check if the number of arguments provided is correct and that the six coordinates are valid numbers of type double dist.exe x1 y1 z1 x2 y2 z2 For example, to calculate the distance between the two points (0, 0, 0) and (1, 1, 1), the program would be run as: dist.exe0 0 0 1 1 1 and the screen output would be 1.73205arrow_forwardModify the craps program to allow wagering inside of C#, and explain each step (reject if you can't). Initialize variable Balance to 1000 dollars. Prompt the player to enter a wager. Check whether the wager is less than or equal to Balance and, if not, have the user reenter the wager until a valid wager is entered. After a valid wager is entered, run one game of craps. If the player wins, increase Balance by wager, and print the new Balance. If the player loses, decrease Balance by wager, print the new Balance, check whether Balance has become zero and, if so, print the message “Sorry. You busted!” (explain steps as much as possible so I can understand plz).The program to modify has the code listed below:// Craps class simulates the dice game craps.using System; class Craps{// create random-number generator for use in method RollDiceprivate static Random randomNumbers = new Random(); // enumeration with constants that represent the game statusprivate enum Status {Continue, Won, Lost}…arrow_forwardThe output of the following program has to be as below: Output: 1. Parent process ID : 02. Child process ID: ....3. Grand Child process ID: ...4. Grand Child process ID: .... 5. Grand Child process ID: ... But when I run the code, the Grand Child processes are not displaying in sequential order as shown in the output. I am trying to write a C program such that the parent process will create one child process and 3 grandchild processes and print their IDs. The Grand Child processes must appear in order of 3,4 and 5. I am attaching my code below. Please tell me what should I change in the code to get the desired output. My Code: #include <stdio.h>#include <sys/types.h>#include <unistd.h>#include <sys/wait.h>int main() {printf("1. Parent process ID: %d\n", getpid());pid_t child;child = fork();if (child<0) {printf("error");}else if (child==0) {printf("2. Child process ID: %d\n", getpid());for (int i=3; i<=5; i++) {pid_t grandchild = fork();if…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning