Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
To make a function return more than one result we pass parameters:
By value.
As int.
By void.
By reference.
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++ (10th 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
- Write a recursive void function that has one parameter that is a positive integer. When called, the function writes its argument to the screen backward. That is,, if the argument is 1234, it outputs the following to the screen: 4321. I've literally tried to create this program and I have no idea how to make it work. Please help me. Is it possible to explain line by line what the code does?arrow_forwardNEED 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_forward
- In 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_forwardMake use of the functions glPolygonMode() and glCullFace() to write a program that can display the front face and back face of a square alternately: It displays the front face in red. When clicking the mouse at the square, it displays the back face in green. When clicked again at the square, it displays the front face again, and so on.arrow_forwardPython 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_forward
- Write a function which takes two integer parameters for values to be added together and returns the result by value. The function may not print anything or read anything directly from the user (i.e. no cin/cout in the function). Assume that the values passed to the function will not be negative, but could be 0 or positive, and will both be integers. The function must implement addition recursively, and cannot use the standalone + operator (only ++) or call any other functions.arrow_forwardWrite a function called Divisors which takes an integer and print all its divisors on the screen. Write the main program to call Divisors function, with an integer x t be taken from the user. Example: if x = 20, then the divisors are: 1, 2, 4, 5, 10, 20.arrow_forwardcan you help me with this problemarrow_forward
- Modify the below code according to what is asking you to do. Show your modified code in a picture, please.arrow_forward4. Be able to write a simple user defined function that you can call and use in another program with a simple formula and some plotting. (i.e. like the kinetic energy example or the other example done in class) Write both the program and the function and show that it works.arrow_forwardWrite a program that calculates the average of a group of test scores. You will ask the user to input each test score individually. When calculating the average, the lowest score in the group is dropped. Your program should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. int findLowest) should find and return the lowest of the five scores passed to it. It should be called by calcAverage(), which uses the function to determine which of the five scores to drop. Void displayAverage() should display the average of the four highest scores. This function should be called by calcAverage(). Input Validation: Do not accept test scores lower…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