Compile Problems

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
double density, viscosity, diameter, speed ;
do{
cout << "Enter Fluid density";
cin >> density ;

cout << "In Enter Viscosity";
cin >> viscosity;

cout << "In Enter Pipe Diameter";
cin >> diameter;

speed=(2000*diameter*density)/viscosity;
cout << " Speed Is:" << endl;
counter ++ ; //Seem to be getting error here

} while (counter <4);

system ("PAUSE");
return 0;
}

........................
Need help please


The variable counter has not been declared in that scope.
Could you elaborate please?
You're asking the program to increment a variable named counter. However, nowhere in your code do you declare it. You've declared four doubles (density, viscosity, diameter and speed) but you haven't declared counter, which should be an integer.

It'll also need to be initialised once declared, otherwise your loop will go nuts.
Topic archived. No new replies allowed.