Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Data validation problem.

Thread Tools

Data validation problem.

chingg1 chingg1 is offline
Junior Member
Join Date: Mar 2012
Posts: 1
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.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying a Validation Error in a Validation Summary Control Lucas Tam ASP .Net 2 02-26-2004 07:49 PM
ASP.NET Web Forms Validation Controls are Server-Side or Client-Side Validation? Matt ASP .Net 14 01-30-2004 09:15 AM
Web form validation vs object validation Colin Basterfield ASP .Net 1 11-29-2003 12:10 AM
validation summary doesnt display when there's client-side validation Libs ASP .Net 0 06-25-2003 03:05 PM
Re: only custom validation control does server side validation? Colin Mackay ASP .Net 0 06-25-2003 07:54 AM