C++ not HTML or CSS

C++ not HTML or CSS
0.0 0


Trying to debug code that finds the area of Square, Rectangle, and Circle. Please Help!! (C++)

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#define PI 3.14
using namespace std;

int main()
	int x, area;

	cout << "Enter the Length of side x : ";
	cin >> x;

	area = x * x;
	cout << "Area of Square : " << area;

	int x, areaofcircle;
		cout << "Enter x: ";

		cin >> x;
		areaofcircle = PI * x * x;

		cout << areaofcircle;

	return 0;



You are including stdafx.h and conio.h which sound like Windows/DOS things. If you are using standard streams such as cin and cout you don’t need them. You do need to include <iostream> which you haven’t. Or is that the empty include in line 2? (I suspect failing to use HTML entities correctly ate up the contents.)

Also you are redeclaring x on line 17.

There are many other things stylisticly wrong with your code but if you fix the unincluded iostream and redeclared x problems, your code will work.


I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


and consider using doubles, so pi is not treated as 3.