How to compile and execute with Visual Studio C++ 2010 (need detailed steps)

Also could you read it and see if i missed anything

//Herons Formula
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double area, perimeter, s;
char A, B, C;

perimeter= A+B+C;
s= perimeter/2;
area= sqrt(s*(s-A)*(s-B)*(s-C));

cout << "This program calculates the area of a triangle";
cout << "What is the length of side A, B, and C, respectively?";
cin >> A >> B >> C;
cout << "The perimeter of the triangle is" << left << setw(8) << perimeter << endl;
cout << "The area of the triangle is " << left << setw(8) << area << endl;
return 0;
}
Multiple posting is not going to get you any help...

Please use code tags (source code) for the code............

I strongly suggest you to do some more reading and review as you lack on the very basics of C++

for the above code:

read on char int and double each one has its own purppose(hint A B and C should be int or double)

Read on the scope of the statments(hint: you have the formulas before the values are entered in this case it will not work properly)

start with this for now and when you get back show some improvement for your own good
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//Herons Formula
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double area, perimeter, s;
	double A, B, C; //should not be char.  Double, float or int will interpret the input as a number.

	perimeter= A+B+C;
	s= perimeter/2;
	area= sqrt(s*(s-A)*(s-B)*(s-C));

	cout << "This program calculates the area of a triangle";
	cout << "What is the length of side A, B, and C, respectively?";
	cin >> A >> B >> C;

	perimeter= A+B+C; //Do this only after setting A, B and C
	s= perimeter/2;   //Otherwise the values are not set when calculated.
	area= sqrt(s*(s-A)*(s-B)*(s-C));

	cout << "The perimeter of the triangle is" << left << setw(8) << perimeter << endl;
	cout << "The area of the triangle is " << left << setw(8) << area << endl;
	return 0;
}
Thank you very much for your help. Check it out I finally finished it with ur help, however I am dealing with more complicated things and I am stuck here:

http://cplusplus.com/forum/beginner/61665/
Topic archived. No new replies allowed.