Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE USE C LANGUAGE ONLY .. NOT JAVA OR C++ Perform sentinel-value iteration w

ID: 1973576 • Letter: P

Question

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

Explanation / Answer

# 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 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 mile is %f Km",miles,distance);

break;

case 2:

printf("Enter distance in km: ");

scanf("%f", &km);

distance= Km* (1/1.609334);

printf("%f Km is %f mile",miles,distance);

break;

case 3: exit;

default: printf("Invalid option selected");

break;

return 0

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote