#include <iostream>
using namespace std;
int rankfun(double left, double right){
 int rank;
 if(left < right){
   rank =-1;
 }
 else if(left > right){
   rank = 1;
 }
 else{
   rank = 0;
 }
 return rank;
}
int main(){
 double number1 = 1.7;
 double number2 = 2.3;
 int result;
 result = rankfun(number1,number2); 
 cout << "The 1st result is:" << result << endl;
 result = 2+rankfun(number2,number1); 
 cout << "The 2nd result is:" << result << endl;
 result = 3*rankfun(number1,number1); 
 cout << "The 3rd result is:" << result << endl;
 result = rankfun(number1+1,number2); 
 cout << "The 4th result is:" << result << endl;
 result = rankfun(number1,5.3); 
 cout << "The 5th result is:" << result << endl;
 cout << "The 6th result is:" << rankfun(7.2,2.8) << endl;

 return 0;
}

What is the return type of function rankfun?

Look at line 3 -- it says it all.

what is rank

What is the output of this program? (The answers have to be numbers.)
The 1st result is:Answer

The 2nd result is:Answer

The 3rd result is:Answer

The 4th result is:Answer

The 5th result is:Answer

The 6th result is:Answer

what is the return type of function main

commented: I see "int" noted in the code. +15

Thank you for such a valuable information. I was looking for a long time detailed explanation. Really appreciate your reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.