Problem with C#

Status
Not open for further replies.

sourav

In the zone
#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.

:?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?:
 

~Phenom~

The No.1 Stupid
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.
 
D

Deleted member 5901

Guest
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 !!!
 
Status
Not open for further replies.
Top Bottom