Write a prototype for the following function:
void printNum(int number)
{
cout << “The number is: “ << number << endl;
}
The prototype for the given function
void printNum(int number)
{
cout << “The number is: “ << number << endl;
}
is
void printNum(int number );
here the return type of the function is void which means it does not return anything to the calling enviornment.
the name of the function is printNum and its argument list contains an integer type whose name is given as number.
An example for the funvtion could be:
void printNum(int number);
int main()
{int a =5;
printNum(a);
return 0;
}
void printNum(int number)
{
cout << “The number is: “ << number << endl;
}
Write a prototype for the following function: void printNum(int number) { cout << “The number...
81. The following function call doesn’t agree with its prototype: cout << BoxVolume( 10, 5 ); int BoxVolume(int length = {1}, int width = {1}, int height = {1}); T__ F__ 82. The following function is implemented to swap in memory the argument-values passed to it: void swap(int a, int b) { int temp; temp = a; a = b; b = temp; ...
Consider the function prototype below. Write the missing function call. float Rent(float , int &); int main() { int d; // Days in hotel. float r=149.55; // Daily Rate (r). float cost; // Total cost of stay of d days. cout << "Daily room rate = $" << r << endl; cout << "#Days you will be staying: "; cin >> d; ______________________________________________ // MISSING statement. cout << "The cost of your stay of " << d << " days...
Modify the program below by replacing the function prototype
"void getScore(int& score);" with "int getScore();"
You need to modify other part of program according to this
change.
//This program reads a course score and prints the //associated course grade #include <iostream> using namespace std; void getScore (int& score); void printGrade (int score); int main () int courseScore; cout << "Line 1 Based on the course score, n" <<"this program computes the" <"course grade." << endl; getScore (courseScore); printGrade (courseScore); return...
#include <iostream> using namespace std; const int SIZE = 10; void displayGreaterThan(int[], int); void displaySmallerThan(int[],int); void displayArrayContent(int[]); void displayLargestValue(int[]); void displaySmallestValue(int[]); int main(){ int number; int numbers[SIZE] = {9,1,90,98,53,22,76,29,37,65}; cout <<"Enter a number: "; cin >> number; cout << endl; displayGreaterThan(numbers,number); cout << endl; displaySmallerThan(numbers,number); cout << endl; displayArrayContent(numbers); cout << endl; displayLargestValue(numbers); cout << endl; displaySmallestValue(numbers); cout << endl; return 0; } void displayGreaterThan(int value[],int num){ cout << " All larger value(s)than" <<...
c++ 1) Write a header file that contains the prototype for a function that takes two value parameters (both floats) and returns a single character output. The function name is “charIn”. We do not care what the function does at this point. (8) 2) Fix the Errors of the C++ program: a. #include <cmath> b. Void main(){cout<< “Math test”<<endl;//start math test c. Int i=10 int j=3 k=i%3 cout << “test of mod<<k<<endl d. Float d=0 float f=e/d cout << “div...
answer in c++ Using the table below, complete the C++ code to write the function prototype statement, and the void function header. The void function should receive three double variables: the first two by value and the last one by reference. Name the formal parameters num1, num2 and answer. The function should divide the num1 variable by the num2 variable and then store the result in the answer variable. Name the function calcQuotient. Also write an appropriate function prototype for...
Give the output for the following code assume int globalvar 10: above the function prototypes void foo(int&); void bar(int); int main() { int globalVar = 5; foo(globalVar); cout << globalVar << endl; bar(globalVar); cout << globalVar << endl; return 0; } void foo(int& x) { x = globalVar + x; cout << globalVar << endl; return; void bar(int x) { globalVar + x; cout << globalVar << endl; X = return;
Design a swap function with the following interface: void swap( int *x, int *y) { } In your main( ), you perform the following test: int main( ) { int a = 10, b = 20; cout << “a = “ << a << “ b= “ << b << endl; swap( a, b); cout << “a = “ << a << “ b= “ << b << endl; return 0; … }
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;
#include using namespace std; void test(); int x = 0; int main(){ cout << x << endl; test(); cout << x << endl; } void test(){ int x = 100; cout << x << endl; for(int x = 0; x < 5; x++){ cout << x << endl; } } how many separate variables named ‘x’ are created?