Hey, I went over your program and made a few corrections. I'm going to bold them in the code. They're pretty simple mistakes but if you have any questions about what I did or why feel free to ask. I changed the spacing to make it easier for me to read. Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
void menu();
void length();
void mm();
int main(int argc, char *argv[])
{
char check[5];
/* loop to rerun program */
do{
menu();
printf("Do you want to continue (y for yes)? ");
scanf("%s", check);
}while(strcmp("y", check) == 0);
system("PAUSE");
return 0;
}
/* Menu Function */
void menu(){
int start;
printf("Enter:\n1 for Length Conversion\n");
printf("2 for Area Conversion\n");
printf("3 for Volume Conversion\n");
printf("4 for Time Conversion\n");
printf("5 for Angle Conversion\n");
printf("6 for Speed Conversion\n");
printf("7 for Acceleration Conversion\n");
printf("8 for Mass Conversion\n");
printf("9 for Force Conversion\n");
printf("10 for Pressure Conversion\n");
printf("11 for Energy Conversion\n");
printf("12 for Power Conversion\n");
scanf("%d", &start);
switch(start){
case 1:
length();
break;
default:
printf("Not valid entry\n");
break;
}
}
/* Length Function */
void length(){
int start;
printf("Enter starting unit: \n");
printf("1 for millimeters\n");
printf("2 for centimeters\n");
printf("3 for meters\n");
printf("4 for kilometers\n");
printf("5 for inches\n");
printf("6 for feet\n");
printf("7 for yards\n");
printf("8 for miles\n");
scanf("%d", &start);
switch(start){
case 1:
mm();
break;
default:
printf("Not valid entry\n");
break;
}
}
/* mm Function */
void mm(){
int end;
double mm;
double ans;
printf("Enter the number of millimeters: ");
scanf("%lf", &mm);
printf("Enter ending unit: \n");
printf("1 for millimeters\n");
printf("2 for centimeters\n");
printf("3 for meters\n");
printf("4 for kilometers\n");
printf("5 for inches\n");
printf("6 for feet\n");
printf("7 for yards\n");
printf("8 for miles\n");
scanf("%d", &end);
switch(end){
case 1:
ans = mm;
printf("%lf millimeters equals %lf millimeters\n", mm, ans);
break;
case 2:
ans = mm/10;
printf("%lf millimeters equals %lf centimeters\n", mm, ans);
break;
case 3:
ans = mm/1000;
printf("%lf millimeters equals %lf meters\n", mm, ans);
break;
case 4:
ans = mm/1000000;
printf("%lf millimeters equals %lf kiloimeters\n", mm, ans);
break;
case 5:
ans = mm/25.4;
printf("%lf millimeters equals %lf inches\n", mm, ans);
break;
case 6:
ans = mm/304.8;
printf("%lf millimeters equals %lf feet\n", mm, ans);
break;
case 7:
ans = mm/1914.4;
printf("%lf millimeters equals %lf yards\n", mm, ans);
break;
case 8:
ans = mm/1609000;
printf("%lf millimeters equals %lf miles\n", mm, ans);
break;
default:
printf("Not valid entry\n");
break;
}
}