Question

Write a prototype for the following function: void printNum(int number) {     cout << “The number...

Write a prototype for the following function:

void printNum(int number)

{

    cout << “The number is: “ << number << endl;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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;

}

Add a comment
Know the answer?
Add Answer to:
Write a prototype for the following function: void printNum(int number) {     cout << “The number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 81. The following function call doesn’t agree with its prototype:              cout << BoxVolume( 10, 5...

    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;        ...

  • Modify the program below by replacing the function prototype "void getScore(int& score);" with "int getScore();" You...

    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...

    #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" <<...

  • answer in c++ Using the table below, complete the C++ code to write the function prototype...

    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...

    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) { }...

    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...

    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 <<...

    #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?

  • Problem 1. Select the running time of each function. void print_array (int* A, int n) for...

    Problem 1. Select the running time of each function. void print_array (int* A, int n) for (int í 0; i < n; ++i) cout << A[i] << endl; void print_array pairs (int* A, int n) for (inti 0; i < n; ++i) for (int j 0; j < n; ++j) cout << Ai] ALj]< endl; void print_array_start(int* A, int n) for (int i 0; i < 100 ; ++i) cout << A[i] << endl; void print_array_alt (int* A, int n)...

  • 1) Fix the Function #include <iostream> void print Num() { std::cout << number; }; int main()...

    1) Fix the Function #include <iostream> void print Num() { std::cout << number; }; int main() { int number = 35; printNum (number); return 0; (Give two ways to fix this code. Indicate which is preferable and why.) #include <iostream> void double Number (int num) {num = num * 2;} int main() { int num = 35; double Number (num); std::cout << num; // Should print 70 return 0; (Changing the return type of doubleNumber is not a valid solution.)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT