Output Problem

Jun 21, 2015 at 2:44pm
How can I get rid of the zero in my output? The squareFloat function says I need to have a return value in that function.

[#include "stdafx.h"
#include "iostream" // Input and output stream
using namespace std; // Meaning you don't have to put std:: before cout <<;.

int squareIntegers(int); // Function Prototype
double squareDouble(double);
float squareFloat(float, float);

int main() //Main Function
{
cout << squareIntegers(22) << endl;
cout << squareDouble(12) << endl;
cout << squareFloat(132, 150) << endl; //Function call and display with value 22 (so x = 22)
system("pause"); // Helps with displaying the output of a program.
return 0; // Returns a value.
}

int squareIntegers(int x) { //Function
int solution; //Declaring the variable solution, which is an integer data type.
solution = x * x; // Squaring x.
return solution; //Returns solution

}

double squareDouble(double d) {
double answer;
answer = d * d;
return answer;
}

float squareFloat(float x, float y) {
float answer1;
float answer2;
answer1 = x * x;
answer2 = y * y;
cout << answer1 << " " << answer2 << endl;
return EXIT_SUCCESS;

//return 0;

}code]
Put the code you need help with here.
[/code]

My output is this:
484
144
17424 22500
0
Jun 21, 2015 at 2:44pm
Sorry about the whole tag issue.
Jun 21, 2015 at 3:03pm
Perhaps you need to look closer at your squareFloat() function.

Why is it returning EXIT_SUCCESS, which is zero, instead of some value you computed in your function?

What exactly are you trying to accomplish in this function, why is it so different from your other "square" functions?

Jun 21, 2015 at 3:25pm
This is different, because it has two calculations. I have tried returning 0, -1. I don't know what to do and I have no choice but to return a value. Any suggestions?
Jun 21, 2015 at 5:07pm
Yeah, but WHY does it have two calculations? Why isn't it like squareIntegers and squareDouble?
Last edited on Jun 21, 2015 at 5:07pm
Topic archived. No new replies allowed.