Tuesday, July 14, 2009

Need help wit 'c' program?(its not executing the answer when im giving a uppercase alphabet)?

#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;ctype.h%26gt;


#include%26lt;stdlib.h%26gt;


main(){


char n;


clrscr();


printf("enter any single character...");


scanf("%c",%26amp;n);


if(isupper(n))


{


printf("given character is a uppercase alphabet\n");


exit(0);


}


printf("given character is not a uppercase alphabet");


getch();


}

Need help wit 'c' program?(its not executing the answer when im giving a uppercase alphabet)?
i use c++, you dont use else in c? if you do, then your code is wrong, (you might notice that your {} are wrong as well),it should be:





if(isupper(n))


{


printf("given character is a uppercase alphabet\n");


exit(0);


}


else


{


printf("given character is not a uppercase alphabet");


getch();


}








----EDIT----


apparently you do use else, so yeah, thats your problem.





http://www.cprogramming.com/tutorial/c/l...
Reply:#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;ctype.h%26gt;


#include%26lt;stdlib.h%26gt;


main(){


char n;


clrscr();


printf("enter any single character...");


n=getchar();


if(isupper(n))


{


printf("given character is a uppercase alphabet\n");


exit(0);


}


printf("given character is not a uppercase alphabet");


getch();


}








Try this. it can help.
Reply:nn is right, you are likely getting BOTH messages, instead of getting just one.


No comments:

Post a Comment