Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 07-10-2009, 12:53 PM   #1 (permalink)
swibit's Avatar
 
True Techie

Join Date: Jun 2009

Location: Europe

Posts: 103

swibit is on a distinguished road

Question My C++ problem

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;
}

swibit is offline  
Old 07-10-2009, 03:04 PM   #2 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,159

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: My C++ problem

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;
}

__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
Old 07-10-2009, 04:11 PM   #3 (permalink)
Baez's Avatar
 

Join Date: Sep 2005

Location: Toronto, Canada

Posts: 5,466

Baez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of lightBaez is a glorious beacon of light

Default Re: My C++ problem

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.
__________________

Baez is online now  
Old 07-11-2009, 05:45 PM   #4 (permalink)
swibit's Avatar
 
True Techie

Join Date: Jun 2009

Location: Europe

Posts: 103

swibit is on a distinguished road

Default Re: My C++ problem

Still hasnt worked. I keep getting like errors and warnings when I compile in Microsoft C++ Visual Express 2008.
swibit is offline  
Old 07-11-2009, 05:51 PM   #5 (permalink)
 

Join Date: Jul 2005

Location: England

Posts: 2,159

kmote has a spectacular aura aboutkmote has a spectacular aura about

Default Re: My C++ problem

The one I posted should work fine, you will have to post your code and errors again.
__________________
MSI P43 Neo|Enermax Pro82+ 425W|E5200|silent 8500GT|250GB Samsung spinpoint F1|Samsung SATA DVD RW|4GB Corsair|Antec SOLO|openSUSE11


There are in order of increasing severity: lies, darn lies, statistics, and computer benchmarks. - diskinfo man page
kmote is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having a strange problem NexDeus Hardware Troubleshooting 4 06-20-2009 01:20 PM
Problem installing software in windows xp pro imagesmith Windows Operating Systems and Software 3 02-20-2008 02:46 PM
Serious computer problem. HeeRoMaKi Hardware Troubleshooting 71 07-28-2007 11:42 PM
Dhcp leasing problem Kloppstock Computer Networking & Internet Access 12 05-13-2007 07:13 PM
cant find the problem... Jhill1 Hardware Troubleshooting 13 05-07-2007 04:51 PM