#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <string>
#include <iomanip>
#include <stdio.h>
#include "windows.h"
#include <fstream>
usingnamespace std;
double largest(int a, int b,int c);
int a=2;
int b=3;
int c=10;
int main()
{
cout<< "numbers to be checked are 2,3, and 10 "<< endl;
largest(2,3,10);
cout<< "the largest number is: "<< endl;
system("pause");
return 0;
}
double largest(int a, int b,int c)
{
if (a>b&&a>c)
{
cout << a;
return a;
}
elseif (b>a&&b>c)
{
cout<< b;
return b;
}
else
{
cout<< c;
return c;
}
}
Hi, at first glance I notice your function largest is returning a double but is not being used.
At line 19 in your program you are returning a double but not doing anything with it, i assume you expect the output to be "the largest number is: largestnumber"
You could add the call to largest into the same line as line 20 and make it look something like
cout << "the largest number is: " << largest(2,3,10) << endl;
alternatively you could change line number 19 to store the largest value in a double and then use that in your statement on line 20. This can be accomplished like so
1 2
double largest_value = largest(2,3,10); // line 19
cout << "the largset number is: " << largest_value << endl; // line 20