My C++ problem

Status
Not open for further replies.

swibit

In Runtime
Messages
111
Location
Europe
Ive just started to code in C++ and in my first hour of learning... I encounter an error.
I know programmers normally encounter lots of debugging but I dont know what Ive actually done wrong. The idea of my program was just to put a function and some input together. I currently am using Visual C++ 2008 Express Edition.. if that makes any difference. This is my program code.
// Square Roots.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <cmath>;

int _tmain(int argc, _TCHAR* argv[])
{` using namespace std;
int x
cout << "What is the number you would like to square root?";
cin >> x;
x= sqrt(x);
cout << x << endl;
cin.get();
return 0;
}
 
C++ isn't my forte but there are lots of problems in there.

Code:
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[])
{ 
    int x;
    cout << "What is the number you would like to square root?";
    cin >> x;
    cout << sqrt(x) << endl;
    return 0;
}
 
Ack where are you getting this information from? That's ancient C++. kmote is right on although in your case you don't need any arguments for main.

"int main()" like that without the quotes is fine.
 
Still hasnt worked. I keep getting like errors and warnings when I compile in Microsoft C++ Visual Express 2008.
 
Status
Not open for further replies.
Back
Top Bottom