Question: I wrote a program: #include /**/ int main(){ int i = 1; while(i !=0){ printf(Hit Enter to quit, or Enter an indenfier: ); char c;

I wrote a program:

#include /**/

int main(){

int i = 1;

while(i !=0){ printf("Hit Enter to quit, or Enter an indenfier: "); char c; int count = 0; int status = 1; char a; if ((c=getchar())==' '){ printf("Thanks for your input. "); break; }else{ while( (c = getchar()) != ' '){ count++;

// if this is the first character of identifire, then it should be either '_' or alphabets if(count == 1){ if((c != '_') && !(c >='A' && c= 'a' && c ='A' && c= 'a' && c = '0' && c

if(count == 0 || status == 0) printf("Invalid "); else printf("Valid ");

}

return 0; }

This giving me the output below:

I wrote a program: #include /**/ int main(){ int i = 1;

It is wrong because it eaxm the valid and invalid from second like 1 in the a1 just skip a in the a1.

But If I deleate the following part:

if ((c=getchar())==' '){ printf("Thanks for your input. "); break; }else{

Then the results are correct, however there is no stop of calling for an input.

How can I fix this to have the program end when type in nothing or type in a specific key?

And the same time always test the validility from the beginning.

CAUsers 54985 Documents\C-Free Projects Study\mingw5MSt Hit Enter to quit or Enter an indenfier Invalid Hit Enter to quit or Enter an indenfier: Invalid Hit Enter to quit or Enter an indenfier: Invalid Hit Enter to quit or Enter an indenfier: Invalid Hit Enter to quit or Enter an indenfier: as Walid Hit Enter to quit or Enter an indenfier: al Invalid Hit Enter to quit or Enter an indenfier: a2 Invalid Hit Enter to quit or Enter an indenfier: Thanks for your input. Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!