Basic homework help :(

Hey guys, I am currently in an online C++ class and needless to say, I am completely lost. I am currently using the C++ for Dummies book (the name is fitting, isn't it?) but my professor's homework assignments are not the same as what is in the chapters of the book. Here's one and what I have so far....

Assignment: Write a program that asks the user to enter the base and height of a triangle, separately, as decimal
numbers, e.g., float B, H , then calculates the triangle’s area using the formula: A=1/2 * B * H

What I have:

#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
// enter base of triangle
int base;
cout << "Enter the base of the triangle:";
cin >> base;

// enter height of triangle
int height;
cout << "Enter the height of the triangle:";
cin >> height;

// calculate formula
}


Like I said, I am EXTREMELY new to all of this and am not even comfortable with the basics yet. Any help is appreciated!

Nicole
What's the problem? You're basically done, except that base and height are required to be floats by the assignment. All that's left is the actual calculation and displaying the result.
float area=0.5f * base * height;
okay, thank you! :) I wasn't 100% sure how to do the actual formula so that helps a lot. Like I said, it's a self-taught online class so it's taking me a while to grasp the concepts of things haha.
Topic archived. No new replies allowed.