Hi,
I wrote a c-progam code , for to print whether the user has entered the digit or charater.
The code is :-
[code=c]
int
main(int argc, char* argv[])
{
int choice;
char ch = '\0';
printf("\n Enter your choice ... :");
ch = getchar();
do
{
printf("\nEnter your choice ... :");
ch = getchar();
if( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <='Z') )
{
puts("\nHello.. . U Entered charater");
}
else if(isdigit(ch))
{
printf("\nThe digit U Entered is :%c", ch);
}
if(ch == '.')
break;
}while(1);
return 0;
}
[/code]
Problem:-
for the first iteration it is working fine, then from the next iteration it is asking me 2 times the printf("Enter your choice..." ); statement.
like this...
Enter your choice ... :
Enter your choice ... :
Plz... help me how to solve this...
Thanks & Regards...
I wrote a c-progam code , for to print whether the user has entered the digit or charater.
The code is :-
[code=c]
int
main(int argc, char* argv[])
{
int choice;
char ch = '\0';
printf("\n Enter your choice ... :");
ch = getchar();
do
{
printf("\nEnter your choice ... :");
ch = getchar();
if( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <='Z') )
{
puts("\nHello.. . U Entered charater");
}
else if(isdigit(ch))
{
printf("\nThe digit U Entered is :%c", ch);
}
if(ch == '.')
break;
}while(1);
return 0;
}
[/code]
Problem:-
for the first iteration it is working fine, then from the next iteration it is asking me 2 times the printf("Enter your choice..." ); statement.
like this...
Enter your choice ... :
Enter your choice ... :
Plz... help me how to solve this...
Thanks & Regards...
Comment