-
Notifications
You must be signed in to change notification settings - Fork 766
Open
Description
```
```
```
```
~~~~
#include <stdio.h>
int main() {
float first, second;
char input;
// Conversion factors
float kmsToMiles = 0.621371;
float inchesToFoot = 0.0833333;
float inchesTocm=2.54;
float kmTom=1000;
while (1) {
printf("\nEnter the input character. q to quit\n");
printf("1. kms to miles\n");
printf("2. inches to foot\n");
printf("3. inches to cm\n");
printf("4. km to m\n");
scanf(" %c", &input); // Note: space before %c to handle newline
switch (input) {
case 'q':
printf("Quitting the program...\n");
return 0;
case '1':
printf("Enter quantity in kms: ");
scanf("%f", &first);
second = first * kmsToMiles;
printf("%f Kms is equal to %f Miles\n", first, second);
break;
case '2':
printf("Enter quantity in inches: ");
scanf("%f", &first);
second = first * inchesToFoot;
printf("%f Inches is equal to %f Foot\n", first, second);
break;
case '3':
printf("Enter quantity in inches: ");
scanf("%f", &first);
second = first * inchesTocm;
printf("%f Inches is equal to %f cm\n", first, second);
break;
case '4':
printf("Enter quantity in km: ");
scanf("%f", &first);
second = first * kmTom;
printf("%f km is equal to %f m\n", first, second);
break;
default:
printf("Invalid input, try again!\n");
}
}
return 0;
}
maddeshiyashushil01-beep
Metadata
Metadata
Assignees
Labels
No labels