I wrote a very simple program in C, but I am not getting any output. I think my functions are not being called, I tried debugging in my IDE but couldn't narrow it down as to why. Please help!!.
Here is the code
/*The distance between 2 cities (in km) is input via keyboard.WAP to
convert & print it in meters, feet, inches and centimetres.*/
#include<stdio.h>
//function to convert & print in meters
int toMeters(int diKM)
{
int meters;
meters=diKM*1000; //convert km to m
printf("En meters, %d esta=%d",diKM,meters);
return 0;
}
int toFeet(int diKM)
{
float feet;
feet=diKM*3280.84; //convert km to feet
printf("En feet, %d esta=%f",diKM,feet);
return 0;
}
int toInches(int diKM)
{
float inch;
inch=diKM*39370.08; //convert to inch
printf("En inch, %d esta=%f",diKM,inch);
return 0;
}
int toCentimeters(int diKM)
{
int cm;
cm= diKM*100000; //convert to cm
printf("En centimeters, %d esta=%d",diKM,cm);
return 0;
}
//main program
int main(){
int km; //store input distance in km
//Ask & take input
printf("How far is it?\n");
scanf("%d\n",&km);
//Call functions to convert & print input
toMeters(km);
toFeet(km);
toInches(km);
toCentimeters(km);
return 0;
}
There is some Spanish which I added for fun. Any suggestions regarding that are welcome too!
Thank you in advance for your valuable time.