PLEASE USE C LANGUAGE ONLY NOT JAVA OR C Perform sentinelva

PLEASE USE C LANGUAGE ONLY .. NOT JAVA OR C++

Perform sentinel-value iteration with a while loop to repeatedly prompt the user to select one of three options: If 1 is input then prompt the user to input kilometers and print the converted value. If 2 is input then prompt the user to input miles and print the converted value If 3 is input then the program will immediately terminate Otherwise the error message \"Invalid option selected\" will be printed out implement the function double convertDistance(int option, double distance) that takes the user input option and distance as arguments and returns the converted distance. 1.609334 kilometers = 1 mile

Solution

# include<stdio.h>

#include<conio.h>

int main()

{ int option;

double distance=0;

printf(\'\'Please select one of the following option :\ 1 to convert from miles to kilometers\\t \ 2 to convert from kilometers to miles\ 3 to exit\");

printf(\"Enter option:\");

scanf(\'\' %d\", &option);

double convertdistance(int option, double distance);

return 0

}

double convertDistance(int option, double distance)

{ float miles,km;

switch(option)

case 1: printf(\"Enter distance in miles: \");

scanf(\"%f\", &miles);

distance= miles * 1.609334;

printf(\"%f\\tmile is %f\\tKm\",miles,distance);

break;

case 2:

printf(\"Enter distance in km: \");

scanf(\"%f\", &km);

distance= Km* (1/1.609334);

printf(\"%f\\tKm is %f\\tmile\",miles,distance);

break;

case 3: exit;

default: printf(\"Invalid option selected\");

break;

return 0

}

PLEASE USE C LANGUAGE ONLY .. NOT JAVA OR C++ Perform sentinel-value iteration with a while loop to repeatedly prompt the user to select one of three options: I
PLEASE USE C LANGUAGE ONLY .. NOT JAVA OR C++ Perform sentinel-value iteration with a while loop to repeatedly prompt the user to select one of three options: I

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site