Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > Standard C, C++
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 03-31-2005, 02:40 PM   #1 (permalink)
destin
Java Junkie
 
destin's Avatar
 
Join Date: Mar 2005
Posts: 40
destin is on a distinguished road
Question Why doesn't this work?

ok this may seem like a silly question.. but why doesn't this work?

Code:
#include <stdio.h> #include <math.h> int main() { double x; printf("Find the square root of: "); scanf("%f", &x); double i = sqrt(x); printf("%f", i); return(0); }
This is what it displays when i input 9:
Code:
Find the square root of: 9 0.000000
__________________

Last edited by destin : 03-31-2005 at 04:50 PM.
destin is offline   Reply With Quote
Old 03-31-2005, 04:53 PM   #2 (permalink)
destin
Java Junkie
 
destin's Avatar
 
Join Date: Mar 2005
Posts: 40
destin is on a distinguished road
Oh.. hmm i changed the
Code:
double x;
and the
Code:
double i = sqrt(x);
to floats and now it works... but why does anyone know why doubles don't work?
__________________
destin is offline   Reply With Quote
Old 03-31-2005, 04:55 PM   #3 (permalink)
destin
Java Junkie
 
destin's Avatar
 
Join Date: Mar 2005
Posts: 40
destin is on a distinguished road
hmm... i got doubles to work using %lf instead of %f.. lol.. i guess you can delete this thread since i just answered my own questions..
__________________
destin is offline   Reply With Quote
Reply


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

vB 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
Can't get loop to work rockybalboa Java 5 03-20-2005 03:54 PM
ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outloo gicio MS Technologies ( ASP, VB, C#, .NET ) 0 12-10-2003 10:05 AM
This should work so why doesn't it ntws01 Standard C, C++ 18 08-27-2003 01:24 PM
San Diego Tech. work. Admin Lounge 10 02-03-2003 06:19 PM
Getting X to work in Debian w00t Linux / BSD / OS X 7 08-25-2002 01:44 PM


All times are GMT -8. The time now is 08:15 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle