new programmer

I have an assignment to create a code in my programming class. I will try to explain it the best that I can. I use Microsoft visual 2013.
Here is the code I found and I am trying to plug it in and I am coming up with error.
I will give you the original one I found and then show you what I have came up with so far.

#include <iostream.h>
#include <math.h>

const float Light_Speed=2.9977925e8;

float main()
{
cout << "Please enter the mass in Kg: ";
float mass
cin >> mass;

if (mass<=0);
{
cout << "Please try again and enter a positive number."
<<endl;
return 0;
}
float energy;
energy=mass * pow (Light_Speed,2;
cout << "The energy is " << energy << '\n';
}

Using 2013 what I don't understand is why if use <> with the header file it dosnt work but if I use "" it works. anyway here is how far I have gotten because I came up with some errors.

#include "stdafx.h"
#include "math.h"

const float Light_Speed=2.9977925e8;

float main()
{

cout

this is where I get my error saying cout is undefined.

when I tried to use Iostream it came up with an error not sure which one but I seemd to have got this to work by changing it to stdafx.h. No one in my class uses 2013 so I am pretty much self taught and I take online classes and sometimes it takes the teacher time to get back to me with that being said she dosnt know how to use 2013.

I hope I put enough information in there. It will be interesting to see which direction I should go.
Include <iostream> without the .h suffix.
Don't you only get a 30 day free trial of for Microsoft visual studio 2013?

Why would you use visual 2013 if you don't know how it works anyway?

Btw it should be <iostream> and std::cout
or if you don't want to write std:: you can add using namespace std;
Last edited on
float main()

The main function should return int, not float.
To answer your question zoran404 it wouldn't really matter which version I used since I am new at it I really wouldn't know how to use any of them to be honest. It appears in my class everyone seems to be using different versions. thanks for the reply's its me going in the right direction.
tannaj2:

Some free IDEs you might want to consider:

http://codelite.org/
www.codeblocks.org

Both are cross-platform, and both come with minGW (if you're not running Linux). I, personally, use codelite.
Ok thanks
Topic archived. No new replies allowed.