Hi, I was assigned a project using Microsoft visual, and its my first time using it so I need some help. I was asked to write a program that converts kilometers to miles, while displaying it.
Heres what I have so far..I think its right, but when I try to run the program it exits right after i type in the Km value and hit enter, it doesnt show the results in miles.. anybody know why?
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
#include %26lt;math.h%26gt;
int main()
%26#123;
/* Declare and initialize variables. */
double km, miles;
/* get the km and mi values from the keyboard*/
printf("Enter distance in kilometers:");
scanf("%lf",%26km);
/* Compute Kilometers to Miles */
miles=km/1.6093340;
/*print Miles */
printf("Kilometers = %f \n", km);
printf("Miles = %f \n", miles);
%26#125;
Microsoft visual c++?ducati
/* Declare and initialize variables. */
double km, miles;
here:
/* get the km and mi values from the keyboard*/
printf("Enter distance in kilometers:");
scanf("%lf",%26km);
if km==0 THEN goto here
/* Compute Kilometers to Miles */
miles=km/1.6093340;
/*print Miles */
printf("Kilometers = %f \n", km);
printf("Miles = %f \n", miles);
No comments:
Post a Comment