-
a prob?
Code:
#include<iostream>
#include<conio.h>
using std::cout;
using std::cin;
using std::endl;
// function prototype
double small(double,double);
int main()
{
// declare varibales
double num1,num2;
// read values
cout<< "Enter two double values:\t";
cin>> num1 >> num2;
// display result
cout<< small(num1,num2);
getch();
}
// define small()
double small(double value1,double value2)
{
// declare alias
double minValue;
// check smallest value
double minValue=value1;
if(value2<minValue)
minValue=value2;
return minValue;
}
It gives me parse errors before functions prototype.
The same code when tries with an integer value gives correct output. What is wrong in this code?
-
You have a redefinition of minValue in your small function and your main doesn't return a value.
-
-
Re: a prob?
Code:
#include<iostream>
#include<conio.h>
using std::cout;
using std::cin;
using std::endl;
// function prototype
double small(double,double);
int main()
{
// declare varibales
double num1,num2;
// read values
cout<< "Enter two double values:\t";
cin>> num1 >> num2;
// display result
cout<< small(num1,num2);
getch();
return 0; // I think recent standards say this is implicit, but why leave it to chance?
}
// define small()
double small(double value1,double value2)
{
// declare alias
double minValue;
// check smallest value
/*double*/ minValue=value1; // You can only define a variable once
if(value2<minValue)
minValue=value2;
return minValue;
}
-