Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 27-05-2010, 12:46 AM   #1 (permalink)
Broken In
 
dharmil007's Avatar
 
Join Date: May 2010
Posts: 133
Default Basic Programme giving Error


HeLLo i m new to C & trying to learn it.
i Wrote a programme but when it runs it givese the values as GARBAGE values.
i Dont know why ??
So can pls anybody gimme a solution

PHP Code:
/*The distance between 2 cities {in km.} is input through 
the Keyboard.WAP to convert & print thsi distance in meters, 
feets, inches & centimeters*/
#include <stdio.h>
#include <conio.h>
void main ()
{
    
float cmkmftinchmtr;
    
clrscr ();
    
printf ("\nEnter Distance {in km} between 2 cities\n");
    
scanf ("\n%f", &km);
    
printf ("\nThe distance between 2 cities is %fkm",km);
    
mtr 1000.0*km;
    
ft 3280.8399*km;
    
cm 100000.0*km;
    
inch 39370.0787*km;
    
printf ("\nThe Convertsion of km to diff units\nMETER = %f\nFEET = %f\nCentiMeter = %f\niNChEs = %f", &mtr, &ft, &cm, &inch);
    
getch ();

dharmil007 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 27-05-2010, 10:30 AM   #2 (permalink)
Sami Hyypiä, LFC legend
 
Liverpool_fan's Avatar
 
Join Date: Jun 2007
Location: Нью-Дели
Posts: 2,138
Default Re: Basic Programme giving Error

scanf ("\n%f", &km);
Remove the "\n" in this line. Write as:
scanf ("%f", &km);

Also:
Don't use Turbo C++, Use MinGW instead as compiler, Geany as IDE
Use int main() and return 0 instead of void main(), main() should always return int in standard C
Don't use clrscr() and getch() or anything which relates to conio.h
Ignore the above if you are more interested in marks than learning.
__________________
Experience true education in Computer Science - http://www.udacity.com | http://www.coursera.org

Spoiler:
Read before asking / messaging any moderator for any query: FAQ + answers for new members

Read all the sticky threads before asking any type of query. Most basic questions are answered in those.
Don't use forum for chatting. Visit http://webchat.freenode.net/?channels=krow, enter nick and connect.
Liverpool_fan is offline   Reply With Quote
Old 09-06-2010, 11:26 PM   #3 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: Basic Programme giving Error

Please read this too.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline   Reply With Quote
Old 16-06-2010, 09:12 AM   #4 (permalink)
Always confused
 
vamsi360's Avatar
 
Join Date: May 2008
Location: Mandriva Control Center
Posts: 349
Smile Re: Basic Programme giving Error

Regarding C++ style of programming, learnt it from the creator himself! I am greatly influenced by his website for some time.

http://www2.research.att.com/~bs/bs_faq2.html
__________________
Vamsi Subhash
visit my blog at www.vamsisubhash.co.cc and taste a bit of IT!
vamsi360 is offline   Reply With Quote
Reply

Bookmarks

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
MSN Messenger installation error Charley Software Q&A 2 25-04-2010 01:48 PM
error 0xc0000007b chirayu garg Software Q&A 1 17-03-2010 04:27 PM
Compaq Presario over heating and blue screen error spider Hardware Q&A 1 22-02-2010 11:52 PM
Due Kernel I/O error, system refuses to boot randomly gary4gar Open Source 33 04-05-2008 10:22 AM
World’s Largest Windows Error Message iMav Random News 46 01-04-2007 07:08 PM

 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:18 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2