Concept explainers
What is the output of the following
#include <iostream>
using namespace std;
void fund(double, int); // Function prototype
int main()
{
int x = 0;
double y = 1.5;
cout ≪ x ≪ " " ≪ y ≪ endl;
func1(y, x);
cout ≪ x ≪ " " ≪ y ≪ endl;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Starting Out with C++ from Control Structures to Objects, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (8th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
Starting out with Visual C# (4th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Problem Solving with C++ (10th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- When should you prefer the use of inline function over not inline function? Explain friend function and the situation in which you should use this concept? Explain with example program.arrow_forwardIf a function is supposed to just display a message, which is more appropriate to use--a value-returning function or a void function?explain pleasearrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forward
- In C++, Which of the following functions is a prototype function? void printWords(){ } int min(int, int, int); double square(double number){ } floor(number); max(4, 6, 2);arrow_forwardHello. I'm working on a triangle and house in C++. I'm a bit confused on how to continue, especially with adding void and arguments. What's Needed: functions in C++. declare function prototypes in C++. use void functions in C++. pass information into functions using arguments. Program Requirement: main should prompt the user for one character and two integer values before drawing a rectangle and triangle by calling the functions appropriately. draw_rectangle is a void function that accepts 3 arguments (the character symbol, integer width, and integer height). It should repeatedly call the draw_bar function to draw the rectangle shape. draw_bar should accept 2 arguments (the character symbol and an integer value width). It will use a loop to draw a horizontal bar of the character. draw_triangle should accept 2 arguments (the symbol and integer height). It should also repeatedly call the draw_bar function to draw the triangle of symbols to the screen as seen in the sample runs.…arrow_forward1. Write a program in python that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3arrow_forward
- I need help making a code be modular, with a function prototype, function definition and function call. Any help on this matter would be greatly appreciated. #include <iostream> using namespace std; double employeePay(double hours, double payRate, double grossPay);double grossPay(double hours, double payRate); int main(){ double hours = 0; double payRate = 0; double grossPay = 0; { while (hours > 40 || hours <= 0) { cout<<"Enter hours between 0-40"<<endl; cout <<"Enter the number hours worked: " ; cin >> hours; } while (payRate > 18.25 || payRate <= 7.5) { cout <<"Pay type must be between $7.50 and $18.25" << endl; cout <<"Enter the pay: " ; cin >> payRate; } { int grossPay = (hours * payRate); cout <<"The gross pay is $" << grossPay; } } }arrow_forward1) Write an iterative function that takes two int type variables named (h) and (k) as the input parameter and calculates the h ** k value and returns the answer. 2) In the main function, take two integers of int type (g) and (b) from the screen. Using the function you created in (1), calculate the value of and print the result on the screen.arrow_forwardImplement in C Programming 6.20.1: Lab training: Unit tests to evaluate your program Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs). Ex: If the input is: 10 the output is: 22.040000 lbs Note: Your program must define the functiondouble KiloToPounds(double kilos) The program below has an error in the KiloToPounds() function. Try submitting the program for grading (click "Submit mode", then "Submit for grading"). Notice that the first two test cases fail, but the third test case passes. The first test case fails because the program outputs the result from the KiloToPounds() function, which has an error. The second test case uses a Unit test to test the KiloToPounds() function, which fails. Change the KiloToPounds() function to multiply the variable kilos by 2.204, instead of dividing. The return statement should be: return (kilos * 2.204); Submit again. Now the test…arrow_forward
- Write function distance that calculates the distance betweentwo points (x1, y1) and (x2, y2). All numbers and return values should be of type double. c++arrow_forwardPlease help me explain the following void function c++ code, which I did not understand. Especially for the first void function and int main(), I do not understand why the first void function enter the number and the int main function print out the final answer. #include <iostream>using namespace std; void getNumber(int *input); void doubleValue(int *val); int main(){ int number; getNumber(&number); doubleValue(&number); cout<<"That value doubled is"<<number<<endl; return 0;}void getNumber(int *input){ cout<<"Enter an integer number:"; cin>>*input; }void doubleValue(int *val){ *val *=2;}arrow_forwarduse c code to Develop a function void printToggled(char str[]) that gets a string as a parameter and prints every lowercase character as an uppercase one and vise versa. For example, if the string submitted as a parameter is Hello WorlD! The function should print hELLO wORLd!arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning