Data validation problem.

Discussion in 'C Programming' started by chingg1, Mar 31, 2012.

  1. chingg1

    chingg1

    Joined:
    Mar 31, 2012
    Messages:
    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. :(
     
    chingg1, Mar 31, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Replies:
    0
    Views:
    2,701
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,523
  3. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    433
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,140
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. bnp
    Replies:
    4
    Views:
    334
Loading...

Share This Page