Can someone take a look at my code, I'm having errors with the end loop.

#include "stdafx.h"
#include <iostream> 
using namespace std; 

int area (int, int); // function prototype
int volume (int, int, int); // function prototype

int _tmain(int argc, _TCHAR* argv[])
{

	int length, width, depth; // parameters for the areas and volumes
	int area;
	int volume;
	int result;

	cout << endl;

	// read in the values of length, width, and depth

	while (depth == 0);
{
   //do something 
} 


	cout << "If you want the result of the calculation to be an area,";
	cout << endl;

	cout << "place a 0 in the depth parameter ";
	cout << endl << endl;

	cout << "Enter a length (postive integer): ";
	cin >> length;

	cout << "Enter a width (postive integer): ";
	cin >> width;

	cout << "Enter a depth (postive integer): ";
	cin >> depth;

	cout << endl;

	if (depth == 0) {
		result = area (length, width);
		cout << "With a length of " << length;
		cout << " and a width of " << width;
		cout << " the area is " << result << endl;
	} else {
		result = volume (length, width, depth);
		cout << "With a length of " << length;
		cout << " a width of " << width;
		cout << " and a depth of " << depth;
		cout << " the volume is " << result << endl;

	} // end if

    END LOOP;

	return 0;

} // end main function

int area (int l, int w) {
	
	int calculation;

	int area (l * w);

	return calculation;
	
} // end area function

int volume (int l, int w, int d) {

    int volume (l * w * d);

	return volume;

} // end volume function

while (depth == 0);
{
//do something
}
Take that ending curly brace down to the line with END LOOP. Remove the semicolon after the first line, too.

Change this:
int calculation;
int area (l * w);
to this:
int calculation = area (l * w);
and similar in the other function definition.

i think it should be

int calculation(l *w);

and the other function seems alright.

My syntax was off. Using my syntax it would be:
int calculation = l * w;

in area() and

int calculation = l * h * d;
return calculation ;

in volume(). I would avoid giving a variable and a function the same name.

I've not used Agni's syntax for plain old data types. Give it a try. If it works, fine.

This article has been dead for over six months. Start a new discussion instead.