Question

Experience with Functions Are the following statements a function header, a prototype or a function call?...

Experience with Functions

  1. Are the following statements a function header, a prototype or a function call?
    1. double calcMonthlyPmt(double amt);
    2. void displayResults()
    3. void showMenu();
    4. showNum(45.67);
    5. area = CalArea(5,10);
  1. Write the function calls for the following headers and prototypes:
    1. void showValue(int quantity)
    2. void display(int arg1, double arg2, char arg3);

pass the following to the call: int age; double income; char initial

  1. double calPay(int hours, double rate);
  1. What is the output of the following program?

#include <iostream>

using namespace std;

void showDouble(int); //Function prototype

int main()

{

int num;

for (num = 0; num < 10; num++)

showDouble(num);

return 0;

}

// Definition of function showDouble

void showDouble(int value)

{

cout << value << ‘\t’ << (value * 2) << endl;

}

Homework Answers

Answer #1

Ans

a) prototype

b) function header

c) prototype

d) function call

e)function call

.

.

showValue(2);

display(age, income, initial);

double output = calPay(2,4.3);

.

.

Output:-

0 0

1 2

2 4

3 6

4 8

5 10

6 12

7 14

8 16

9 18

.//here output ends

prototype have return type written before function name and semicolon at end

function header do not have semicolon at end

function call do not have return type and end with semicolon.

.

function parameters are passed in paranthesis, and return is taken in some variable if not void.

.

the main function has loop that runs from 0 to 10 and call function 10 times. In each call value and its product with 2 is printed separated by tab and line change after print.

.

.

If any doubt ask in the comments.

Please appreciate the work by giving a thumbs up.

.

Know the answer?
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
Similar Questions
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath>...
Please write variables and program plan (pseudocode) of the C++ programming below: #include <iostream> #include <cmath> using namespace std; void divisors(int num); int main () {    char repeat;    int num;       while (repeat !='n')    {        cout << "Enter a number: ";        cin >> num;        divisors(num);        cout << "Continue? (y or n): ";        cin >> repeat;    }    return 0; } void divisors(int num) {   ...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits from base class Account and include an additional data member of type double that represents the fee charged per transaction (transactionFee). Write Checking- Account’s constructor that receives the initial balance, as well as a parameter indicating a transaction fee amount. If transaction fee is less than zero, the transactionFee will be set to zero. Write the chargeFee member function that updates the balance by...
Write a program containing a function, reverseDigit, that takes an integer as a parameter and returns...
Write a program containing a function, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed, then printout the return result. For example, the value of reverseDigit(12345) is 54321; the value of reverseDigit(5600) is 65; the value of reverseDigit(7008) is 8007; and the value of reverseDigit(-532) is -235.    Modify the following program to make a correct output. /* // Name: Your Name // ID: Your ID // Purpose Statement: ~~~ */ #include <iostream>...
my code has several functions; delete and backward functions are not working, rewrite the code for...
my code has several functions; delete and backward functions are not working, rewrite the code for both functions and check them in the main: #include<iostream> #include<cassert> using namespace std; struct nodeType {    int info;    nodeType *link; }; class linkedList { public:    void initializeList();    bool isEmptyList();    void print();    int length();    void destroyList();    void insertFirst(int newItem);    void insertLast(int newItem);    int front();    linkedList();    void copyList(const linkedList otherList);    void insertNewValue(int value);...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment...
C++ please Write code to implement the Karatsuba multiplication algorithm in the file linked in Assignment 2 (karatsuba.cpp) in Canvas (please do not rename file or use cout/cin statements in your solution). As a reminder, the algorithm uses recursion to produce the results, so make sure you implement it as a recursive function. Please develop your code in small The test program (karatsuba_test.cpp) is also given. PLEASE DO NOT MODIFY THE TEST FILE. KARATSUBA.CPP /* Karatsuba multiplication */ #include <iostream>...
Implement the body of the swap function using the indirection operator // finish this program so...
Implement the body of the swap function using the indirection operator // finish this program so that the values of // x and y are swapped in main(). #include <iostream> using namespace std; void swap(int* first, int* second) { // IMPLEMENT THIS FUNCTION // YOUR CODE GOES HERE } int main() { int x = 9; int y = 2; swap(&x, &y); cout << "x: " << x << endl; cout << "y: " << y << endl; // if...
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is...
Menu.cpp isn't working. C++  utilize inheritance to create a banking app. The architecture of the app is up to you as long as you implement some form of inheritance. Below is my code however the credit and the actual menu isn't working. Can i get some help on getting the menu to work properly. // BankAccount.h #ifndef ACCOUNT_H #define ACCOUNT_H #include <string> #include <iostream> using namespace std; class BankAccount { protected : int noOfWithdrawls; private: // Declaring variables    float balance;...
Please fill in the blank bolded below that would be the best choice for this program....
Please fill in the blank bolded below that would be the best choice for this program. #include <iostream> using namespace std; const int size = 100000; class TheBig { public: double operator[](int index) const {return (theData[index]);} private: double theData[size]; }; void firstToBeThe( ______________________________________________________) { for (int i = 0; i <size; i++) cout << value[i] <<endl; } int main() { TheBig one; firstToBeThe(one); }
Complete the missing code for the constructors as indicated in the comments in all three header...
Complete the missing code for the constructors as indicated in the comments in all three header files. C++ mainDriver.cpp #include <string> #include "Address.h" #include "Date.h" #include "Person.h" using namespace std; int main() {    Person p1;    Person p2("Smith", "Bobby", "[email protected]", 111, "Main St", "Clemson",            "SC", 29630, 1, 31, 1998);    cout << endl << endl;    p1.printInfo();    p2.printInfo();    return 0; } Person.h #ifndef PERSON_H #define PERSON_H #include <iostream> #include <string> using namespace std; class...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are...
Functions displayGrades and addGrades must be rewritten so that the only parameters they take in are pointers or constant pointers. Directions: Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS = 3; // may only be declared within the main function string students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Be sure to compile using g++ -std=c++11 helpWithGradesPtr.cpp Write a C++ program to run a menu-driven program with the...