#include <iostream>
using namespace std;
int rankfun(double left, double right){
 int rank;
 if(left < right){
   rank =-1;
 else if(left > right){
   rank = 1;
   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;

Recommended Answers

Answered by ravi_14 0 in a post from

type name ( parameter1, parameter2, ...) { statements }

- type is the type of the value returned by the function.
- name is the identifier by which the function can be called.
- parameters (as many as needed): parametes.
[Click Here](http://www.cplusplus.com/doc/tutorial/functions/)

Jump to Post
Answered by Danish_13 15 in a post from

what is the return type of function main

Jump to Post

All 6 Replies

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, learning, and sharing knowledge.