1

The functions that I tried calling can't be called. Although when I remove the data type they are called but when I tried putting a data type it wont work. It compiles but shows blank screen

Haven't tried anything yet as this is my first time encountering this

Function 1

double computeGrossPay(int hoursWorked, int perHourRate){
    double grossPay = hoursWorked * perHourRate;
    cout << "This is the computed Gross Pay"<<grossPay<<endl;
    return grossPay;
}

int main (){
    double computeGrossPay(int hoursWorked, int perHourRate);
}

No error but no Results(Blank CMD)

Simson
  • 3,373
  • 2
  • 24
  • 38
HeIIshh
  • 11
  • 1
  • Hi Hellshh, could you provide some more details to your issue? Which IDE, which compiler do you use? Have you included `iostream`? Could you provide your full code in order to make it reproducible? Thanks. – CKE Oct 08 '19 at 06:01
  • How do I post the full code here sir? – HeIIshh Oct 08 '19 at 06:10
  • 1
    @HeIIshh to post the full code, well, post the full code in your question. Use the `{}` icon to format the code part of the question. But anyway, you don't want to post the full code, you want to post a [mcve]. – Jabberwocky Oct 08 '19 at 06:12
  • "when I remove the data type they are called when I tried putting a data type it wont work" is an indication that the version with types is not a function call. There is a list of good C++ books [here](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Oct 08 '19 at 06:48

1 Answers1

5

double computeGrossPay(int hoursWorked, int perHourRate); doesn't call the function, it just declares it.

You probably want something like:

int main (){

  double myresult = computeGrossPay(10, 20);
  // do something with myresult...
}

By the way, it's pointless to have a result type double if both parameters of the function are ints. I let you find out why as an exercise.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115