I have some problem with my program, it won't run into the
Code:
if (selection2=='y'){
system("clr");
return main();
}
please help me with this
Code:
#include<stdio.h>
#include<stdlib.h>
int main(){
float km,ml,result;
int selection;
char selection2;
printf("\n\nPlease select the mesurement unit you want to convert with\n");
printf("1) Kilometer\n2) Mile\n");
scanf("%d",&selection);
if (selection==1){
printf("\nPlease enter the kilometers \n");
scanf("%f",&km);
result=km*0.621371;
printf("\n %.2f km = %.2f mile",km,result);
}
else if (selection==2){
printf("\nPlease enter the miles \n");
scanf("%f",&ml);
result=ml/0.621371;
printf("\n %.2f mile = %.2f km",ml,result);
}
else if(selection!=1 && selection!=2){
printf("Error, Do you want to restart the program (y/n)");
scanf("%c",&selection2);
if (selection2=='y'){
system("clr");
return main();
}
else
return 0;
}
getchar();
return 0;
}