Hey guys i have been working on a report card program lately and i hit a hard place i used a do-while but i cant restrict characters from being posted without the program crashing and i don't wanna be monotamous so can u guys help heres a piece of the code

phys: // this is the report error system//

 do {

               printf ("Input physics grade :\n");
                scanf("%f", &phys );

                 if (phys > 100|| phys <0) {

                     printf("Skipping the value\n");
                      /* jumps to second iteration */


this is a part of my code so could you help me?

Recommended Answers

All 3 Replies

fflush(stdin) is like trying to flush your kitchen sink.

Flushing only works on output streams (like the toilet in your home), not on input streams, like your kitchen faucet. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.