problem with conversion of units like km to m etc...
Our teacher have asked us to make a program in C language to read the difference between two cities in km, m, cm, inches and feets... I have tried every hell to make this work... I am not able to combine it all together... please help!!! I am so confused.
here is sum rough work i have done:
km-1
m-km/1000
cm-m/1000
1inch-2.54cm
1feet-12 inch
u first try the conversion of one form to another first.
After u have tested all of them in individual programs u can try to integrate them............
u first try the conversion of one form to another first.
After u have tested all of them in individual programs u can try to integrate them............
it doesn't work actually they have not taught us all this jus da simple stuff and now they expect us to make something we have never done before don't even have a hint but i went through a tutorial with similar kind of thing... i'll show you what i did but it just shows 0,0,0 n 0 lol! something is badly wrong with the script!!!
#include<stdio.h>
#include<conio.h>
void main();
{
int km=0;
int meter =0;
int cm=0;
int inches=0;
int feet=0;
const int km_per_meter=1000;
const int meter_per_cm=1000;
const int cm_per_inches=2.54;
const int inches_per_feet=12;
printf("Enter distance of city 1 in Km: ");
scanf("%d",&inches);
meter=km/km_per_meter;
cm=meter/meter_per_cm;
inches=cm/cm_per_inches;
feet=inches_per_feet;
print("that is equivalent to %d meter; %d cm; %d inches and %d feets\n",meter,cm,inches,feet);
}
getch();
}