Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5.1, Problem 4STE
Program Plan Intro
void Functions:
- A function must either return a single or no value at all.
- A function that does not return a value is termed as “void” function.
- The “void” function is been defined in same way as function that would return a value.
- It implements only subtask for the complete problem.
- If a “void” function is called, formal parameters are substituted with arguments.
- The statements in function body are executed.
- The “return” statement specifies the value that is been returned.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write the definition of a void function that takes as input three decimal numbers. The function returns the sum and average of the three numbers. If the average is greater than or equal to 70, it returns "Pass"; otherwise it returns "Fail".
In this project, you should design a Date class and use it to create a calendar application that has
many features. You are not limited to the features included in these instructions, feel free to add
any other components you find useful.
Note: A normal year has 365 days. A leap year has 366 days (the extra day is February 29). In this
project, you must take this fact into account. The rules that determine leap years are provided later
in these instructions.
Design the Date class, to be used in your application, containing:
A private data member month of type integer that holds the date's month.
A private data member day of type integer that holds the date's day.
A private data member year of type integer that holds the date’s year.
A default constructor that sets the date to January 1, 1753.
Accessors for each member variable.
Mutators for each member variable.
A member function that prints on the screen a date in the form mm / dd / yyyy.
A member function that returns the day name of…
hello, how would I solve this and could you please explain each step and the reason for it? Thank you so much.
Chapter 5 Solutions
Problem Solving with C++ (9th Edition)
Ch. 5.1 - What is the output of the following program?...Ch. 5.1 - Are you required to have a return statement in a...Ch. 5.1 - Suppose you omitted the return statement in the...Ch. 5.1 - Prob. 4STECh. 5.1 - Prob. 5STECh. 5.1 - Is a call to a void function used as a statement...Ch. 5.2 - What is the output of the following program?...Ch. 5.2 - What would be the output of the program in Display...Ch. 5.2 - What would be the output of the program in Display...Ch. 5.2 - Prob. 10STE
Ch. 5.2 - Write a void function definition for a function...Ch. 5.2 - Prob. 12STECh. 5.3 - Prob. 13STECh. 5.3 - Prob. 14STECh. 5.3 - Rewrite the function declaration comment for the...Ch. 5.3 - Prob. 16STECh. 5.4 - Prob. 17STECh. 5.4 - Prob. 18STECh. 5.4 - Prob. 19STECh. 5.4 - Prob. 20STECh. 5.4 - Prob. 21STECh. 5.4 - Write a stub for the function whose function...Ch. 5.5 - Prob. 23STECh. 5.5 - Prob. 24STECh. 5.5 - Prob. 25STECh. 5 - Write a function that computes the average and...Ch. 5 - Write a program that reads in a length in feet and...Ch. 5 - Write a program like that of the previous exercise...Ch. 5 - (You should do the previous two Practice Programs...Ch. 5 - Write a program that reads in a weight in pounds...Ch. 5 - Write a program like that of the previous exercise...Ch. 5 - (You should do the previous two Practice Programs...Ch. 5 - (You need to do Practice Programs 4 and 7 before...Ch. 5 - The area of an arbitrary triangle can be computed...Ch. 5 - Write a program that converts from 24-hour...Ch. 5 - Write a program that requests the current time and...Ch. 5 - Modify your program for Programming Project 2 so...Ch. 5 - Write a program that tells what coins to give out...Ch. 5 - In cold weather, meteorologists report an index...Ch. 5 - Prob. 6PPCh. 5 - Write a program that inputs a date (for example,...Ch. 5 - Complete the previous Programming Project and...
Knowledge Booster
Similar questions
- NEED HELP WITH THIS import random print(random.randint(1,6)) #prints a number between 1 and 6. #or: x = random.randint(1,6) print(x) #prints a number between 1 and 6. write a python program that simulates a game with two dice roll based on their sum and value. Your program should: Define a function try_your_luck(dice1, dice2) that takes two arguments i.e., the numbers generated by randint() function (use randint twice). The random numbers should be passed to the function as argument The player wins some money, when: a. Sum of both dice is divisible by three, player wins $5 b. Same number on both die, player wins $10 c. For all other cases, print "try again" Player loses the game, when: a. Sum is greater than 10 and odd b. Sum is 7. Display an appropriate message for each case (player wins or loses).arrow_forwardWrite a function to divide variable ‘a’ with ‘b’. Store the result in a separate variable andreturn it from the function. Practice default parameters by calling your function with 1 argumentand with 2 arguments. Use the concept of function prototyping for this question. The signature offunction is as follows: int divide (int a, int b=2)arrow_forwardIn Java: Develop a void function that takes two integers and prints whether the first number is divisible by the second. For example, with arguments 51 and 17, the function should print “51 is divisible by 17”. With arguments 17 and 8, the function should print “17 is not divisible by 8”. Call the function twice with different arguments to show each possible result. What happens when the second argument is greater than the first?arrow_forward
- program with a function. program with a function.arrow_forwardDefine a function with the prototype void show_binary (int); that consumes a positive integer and prints a binary representation of that integer over multiple lines. The top line will be the one's place, the next line the two's, etc. (Reading from bottom to top would be the same as the usual way of reading left to right.) Follow the procedure demonstrated in class. For example: Test Result show_binary (11); 1 1 0 1arrow_forwardCreate a program that accepts an integer N, and pass it to the function generatePattern. generatePattern() function which has the following description: Return type - void Parameter - integer n This function prints a right triangular pattern of letter 'T' based on the value of n. The top of the triangle starts with 1 and increments by one down on the next line until the integer n. For each row of in printing the right triangle, print "T" for n times. In the main function, call the generatePattern() function. Input 1. One line containing an integer Output Enter N: 4 T TT TTT TTTTarrow_forward
- Create a Geometry Calculator program that calculates the circumference of a circle, the area of a circle, and the volume of a sphere with a user inputted radius. You will implement this by creating four functions: A function that gets user input for a new radius and returns the value. A function that is passed the current radius, calculates the circumference of a circle, and returns that value. A function that is passed the current radius, calculates the area of a circle, and returns that value. A function that is passed the current radius, calculates the volume of a sphere, and returns that value. A function that is passed the current radius, returns nothing but only displays the following menu: GEOMETRY CALCULATOR 1) Input a new radius (Currently r = 1) 2) Circumference of Circle 3) Area of Circle 4) Volume of Sphere 5) Exit ________________________________ Please enter an option from the menu: Within the "main" function use a switch statement within a do - while loop to…arrow_forwardCan you help me with this question ?arrow_forwardhello, how would I solve this and could you please explain each step and the reason for it? Thank you so much.arrow_forward
- Python question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. In written text small numbers are often written out, e.g. you'd write 'I have twobrothers and one sister', rather than 'I have 2 brothers and 1 sister'. In this problem youwill implement a function convertSmall() that takes as input a text (i.e., string) s andreturns the text s with small numbers (integers between 0 and 6) converted to their names.>>> convertSmall('I have 2 brothers and 1 sister')'I have two brothers and one sister'>>> convertSmall('I have 8 brothers and 5 sisters')'I have 8 brothers and five sisters'arrow_forwardThe following program contains a simple class that is designed to allow a user to enter an integer value within a specific range. The code prompts the user with a message that explains the limits of the valid range of values, but it does not force the user to enter legal values. We have examined a number of approaches for dealing with this problem. One approach is to place an assert statement in the getValue function to terminate the program when an illegal input occurs. An alternative approach is to put a loop inside the getValue function that prompts the user repeatedly until a valid value is received. Neither of these approaches is satisfactory, because they force the user to adopt a specific approach to dealing with the error. If you compare the execution of a program with the operation of a business, you will notice that both consist of a hierarchy of classes and functions. In a business, we expect the people in the upper layers of the company (managers) to set policies and the…arrow_forwardcan you help me with this problemarrow_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