Need help fixing these two programs, I\'m really new to c++ so the little things
ID: 668229 • Letter: N
Question
Need help fixing these two programs, I'm really new to c++ so the little things are hard to find
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "The area of a triangle with base 1 and height 5 is "
<< << endl;
area = (4+3)/2;
cout << "The area of a triangle with base 4 and height 3 is"
<< area << '.';
cout << 'The area of a triangle with base 3 and height 6 is '
<< area << '.';
return 0;
}
____________________________________________________________________________________-
#include <iosteam>
#include <cmath>
int main()
{
double X;
int Y;
/* Read in x /*
cout >> "Enter x (float): ";
cin << x;
/* Compute sqrt(x) /*
y = sqrt(x)
cout << "sqrt(x) = " y << endl;
cout << "x^2 = " x^2 << endl;
cout << "x^3 = " x^3 << endl;
return 0;
}
Explanation / Answer
1)
#include<iostream>
using namespace std;
int main()
{
int area;
area = (1+5)/2;
cout << "The area of a triangle with base 1 and height 5 is "<< area << endl;
area = (4+3)/2;
cout << "The area of a triangle with base 4 and height 3 is" << area << '.';
area = (3+6)/2;
cout << "The area of a triangle with base 3 and height 6 is "<< area << '.';
return 0;
}
2)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x;
int y;
/* Read in x /*
cout >> "Enter x (float): ";
cin << x;
/* Compute sqrt(x) /*
y = sqrt(x);
cout << "sqrt(x) = " << y << endl;
cout << "x^2 = " << x^2 << endl;
cout << "x^3 = " << x^3 << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.