My friend has this program due tomorrow & she can't figure out what's wrong. These stupid 0's keep popping up before & after her output & I don't know much on this other then what she telling me to explain on here. Here's her program if anyone can figure it out..that'd be awesome! //########################################################## //# //# Kim //# CSCI 151 Summer 2004 //# Dev C++ 4.9.8.9 //# //# This program will ask the user for the length //# of the side of a cube, and in result will calculate //# how the largest sphere will fit in it. //# //########################################################## #include <iostream> #include <iomanip> #include <cmath> #include <cstdlib> using namespace std; //Declare named constant for PI const double PI = 3.1415926; int main() { //Declare variables double radius = 0.0; double side = 0.0; double sphere_volume = 0.0; double cube_volume = 0.0; double sphere_sa = 0.0; double cube_sa = 0.0; double diameter = 0.0; double volume_between = 0.0; double fixed = 0.0; double showpoint = 0.0; double left = 0.0; double right = 0.0; //Get input from user cout<<"Please enter the length of the side of the cube: "; cin>>side; //Calculate stuff radius = side/2.0; cube_volume = pow(side, 3); cube_sa = 6.0 * pow(side, 2); sphere_volume = 4.0/3.0 * PI * pow(radius, 3); sphere_sa = 4.0 * PI * pow(radius, 2); diameter = side; volume_between = cube_volume - sphere_volume; //Output Section cout<<fixed<<showpoint<<setprecision(3); cout<<left<<setw(24)<<"Radius of the largest sphere that could fit in the cube: "<<right<<setw(12)<<radius<<endl; cout<<left<<setw(24)<<"Volume of the cube: "<<right<<setw(12)<<cube_volume<<endl; cout<<left<<setw(24)<<"Surface area of the cube: "<<right<<setw(12)<<cube_sa<<endl; cout<<left<<setw(24)<<"Volume of the largest sphere that could fit in the cube: "<<right<<setw(12)<<sphere_volume<<endl; cout<<left<<setw(24)<<"Surface area of the largest sphere that could fit in the cube: "<<right<<setw(12)<<sphere_sa<<endl; cout<<left<<setw(24)<<"Volume of the space in between the cube and the sphere: "<<right<<setw(12)<<volume_between<<endl; system ("pause"); return 0; }

I think it's because "fixed", "showpoint", "left", and "right" are initialized to 0.0. She never assigns them different values (something other than 0.0). Then she displays them to the screen. Since they are 0.0 she is seeing "0.0" before and after her real output.

This is part of the problem. fixed, showpoint, left and right are iostream manipulators that are provided if you #include <ios>. Get rid of the variables for fixed, showpoint, etc. and #include <ios> and see if that helps.

You get zeros printed out before and after the output? That is simple to solve. Just take a look at this little bit of the code: In the cout statement, you have it print out showpoint on the first line, so that will always print out zeros (because you never change its value to something other then zero. In this cout statement, you first print out left (which is always zero because you never change the value). Then you print out the text. Then you print out right (which is also always zero because you never change the value). So in summary, this program will always print out lots of zeros because you are explicitly telling it too. Now, the question is, what is the point of the left, right, and showpoint variables? Why were they put there? Why are you always printing them out when they are always zero?