Hii guys ,
i've to create a program for my assignment that calculate no of mol , pressure , volume and temperature.
and the code appears to be like this ,
float vol , mol , temp , pressure;
printf("Please enter the volume : ") ;
scanf("%f", &vol) ;
printf("Please enter the number of mole : ") ;
scanf("%f", &mol) ;
printf("Please enter the temperature : ") ;
scanf("%f", &temp) ;
pressure=(mol*0.082057*temp)/vol ;
printf("The pressure is %.2f\n\n", pressure) ;
the problem is whenever i input alphabet the program will go insane. Can anyone help me to solve this problem? The input can be only numerical values , others than that it will prompt the user to reenter the input. Have to pass up on monday.
i've to create a program for my assignment that calculate no of mol , pressure , volume and temperature.
and the code appears to be like this ,
float vol , mol , temp , pressure;
printf("Please enter the volume : ") ;
scanf("%f", &vol) ;
printf("Please enter the number of mole : ") ;
scanf("%f", &mol) ;
printf("Please enter the temperature : ") ;
scanf("%f", &temp) ;
pressure=(mol*0.082057*temp)/vol ;
printf("The pressure is %.2f\n\n", pressure) ;
the problem is whenever i input alphabet the program will go insane. Can anyone help me to solve this problem? The input can be only numerical values , others than that it will prompt the user to reenter the input. Have to pass up on monday.