The area of a triangle with the sides of lenght a, b, c can be computed by the formula
A= sqrt(s*(s-a)*(s-
where s = (a+b+c)/2. write the program in C++ which will ask for the lenghts of the three sides, and output the area of the triangle.
Heres what i have so far but im stuck( we must also send the output to both screen and and a file) and i cant use looping
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
using namespace std;
int main ()
{
string first_name, last_name;
cout << " Please enter your first name : " ;
cin >> first_name;
cout << " Please enter your last name : " ;
cin >> last_name;
cout << " Hello " << first_name << Last_name << endl;
cout << "Plese enter the three lenghts: " ;
cin >> a >> b >> c ;
double a, b, c;
double s;
double Area;
ofstream outFile; //File the results of calculations
//
//Computations
s = (a + b + c)/2;
Area=sqrt(s * (s-a) * (s-
//d
cout << "The area of the triangle with sides ... " << endl;
This post has been edited by malmazan1: 22 September 2011 - 11:36 AM

New Topic/Question
Reply



MultiQuote





|