If statement for different choice
#include <stdio.h>
int main(void)
{
float num;
int choice;
printf("1: Change Feet to Meters, 2: Change Meters to Feet. ");
printf("Choice: ");
scanf("%d", &choice);
if(choice == 1) {
printf("Enter number of feet: ");
scanf("%f", &num);
printf("Meters: %f", num / 3.28);
} else {
printf("Enter number of meters: ");
scanf("%f", &num);
printf("Feet: %f", num * 3.28);
}
return 0;
}
Related examples in the same category