Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 21-05-2005, 04:02 PM   #1 (permalink)
In The Zone
 
sourav's Avatar
 
Join Date: Aug 2004
Location: Bhubaneswar, Orissa
Posts: 405
Default Problem with C#


Quote:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int km;
float m,cm;
printf("Enter distance between two places = ");
scanf("%d",&km);
m=km*1000;
cm=m*100;
printf("Distance in meters = %f",m);
printf("\nDistance in centimeters = %f",cm);
getch();
}
on entering no. above 30 it has some problems. If I go above 30 it shows wrong negative ans.

sourav is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 21-05-2005, 11:42 PM   #2 (permalink)
The No.1 Stupid
 
~Phenom~'s Avatar
 
Join Date: May 2005
Location: CYBERYARD
Posts: 1,708
Default

hi saurav. It seems u r new to C or C++. its real simple. for inputs above 30 , the result is bound to go negative, as the datatype u r using is int .rather u should use "long int" in place of int. this should solve ur problem.if not , PM me n i will send u the sol.
__________________
n00b forever...
~Phenom~ is offline  
Old 22-05-2005, 05:59 AM   #3 (permalink)
Human Spambot
 
expertno.1's Avatar
 
Join Date: May 2005
Location: Expert Planet
Posts: 2,480
Default

rajrulesdear is right and i think there is a PM kidding all over the forum
__________________
Off From Digit Forum for some months.....busy
expertno.1 is offline  
Old 22-05-2005, 02:07 PM   #4 (permalink)
In The Zone
 
Join Date: May 2005
Location: JABALPUR (M.P)
Posts: 403
Default

wat do u mean by pm kidding?
__________________
\"Live Life as it comes & Live it KINGSIZE\"
\"Learn From Yesterday,Live For Today & Hope For Tomorrow\".
Bye 4 Now - N_!_r_a_L
King_Niral is offline  
Old 22-05-2005, 02:11 PM   #5 (permalink)
In The Zone
 
Join Date: May 2005
Location: JABALPUR (M.P)
Posts: 403
Default

hey another thing !!! the program written above is not C++ it is a c based program!!!!

Coz in c++ cout<<"The line to print on screen comes here !!!";

sourav r u in school? 11th or 12th cbse????

or maybe ur upgrading from C to C++ !!!!!????????

cheers !!!
__________________
\"Live Life as it comes & Live it KINGSIZE\"
\"Learn From Yesterday,Live For Today & Hope For Tomorrow\".
Bye 4 Now - N_!_r_a_L
King_Niral is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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


 
Latest Threads
- by Sujeet
- by gforz
- by soumya

Advertisement




All times are GMT +5.5. The time now is 03:22 PM.


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

Search Engine Optimization by vBSEO 3.3.2