Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
C++ Problem

 
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum
Author Message
CMAN
Just In
Just In


Joined: 29 Sep 2004
Posts: 1

Post Post subject: C++ Problem Reply with quote

What is wrong with this code? my book says it's ok, but not my compiler.:

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = 0.0;
double n = 1;

cout << "Number to round: ";
cin >> x;
cout << "Decimal places: ";
cin >> n;

x = x * pow(10, n);
x = x + 0.5;
x = floor(x);
x = x / pow(10, n);

cout << x << endl;

return 0;
}

The 'n's in 'pow' don't read but numbers do.
Wed Sep 29, 04 7:00 pm
Back to top
CMAN View user's profile Send private message
hasnut
Expert User
Expert User


Joined: 28 Aug 2004
Posts: 201

Post Post subject: Reply with quote

Which Complier ver you are using?
_________________
Sarder Hasnut
MCSD, CIW A

Need Low Cost Prefessional Hosting Contact me
Thu Sep 30, 04 12:32 pm
Back to top
hasnut View user's profile Send private message Visit poster's website MSN Messenger
dinangkur
Super Moderator
Super Moderator


Joined: 24 Mar 2004
Posts: 491
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

It definitely a problem with your complier. I compile the program with GCC in my Linux. It's working fine. You should check with your complier version. If you're using windows then you better choose Borland suite or Borland 5.2

I think both will work fine.

-DK
_________________
...we too are stardust...
Mon Oct 04, 04 2:25 am
Back to top
dinangkur View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
lalitgoyal
Just In
Just In


Joined: 22 Oct 2004
Posts: 1
Location: india

Post Post subject: Reply with quote

hi,

it will work , no problam with code, please put the exect error given by the compile and do tell us which compiler you are using..
Fri Oct 22, 04 9:47 am
Back to top
lalitgoyal View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group