![]() |
how to avoid to printing the value of charecter in C?
Hi Friends,
I wrote a program in c to print a table for ant in teger as shown below /**----------------------------------------**/ int a,b,c; printf("Enter the value of a\n"); scanf("%d",&a); for(b=1; b<= 20; b++) { c=a*b; printf("%d X %d = %d\n",a, b,c ); } /**-----------------------------------------**/ This program is working fine,when i give input as a number. However, [COLOR=DarkRed]in case,the given input is a charecter,[/COLOR] Then it is showing some different output. |
Re: how to avoid to printing the value of charecter in C?
Thats because the character when converted into ASCII and multiplied will be numbers not as per expectation and so its giving unexpected output.
|
Re: how to avoid to printing the value of charecter in C?
Hi Shabbir,
Thankyou very much for your reply. Now what is the solution? how can i use the function "isalpha()" to avoid the above problem |
Re: how to avoid to printing the value of charecter in C?
Code:
char c; |
Re: how to avoid to printing the value of charecter in C?
Check This code ( I only use cout and cin instead of scanf() and printf() )
Code:
#include <iostream>Quote:
Regards |
Re: how to avoid to printing the value of charecter in C?
Thanks allot!!!!
|
| All times are GMT +5.5. The time now is 18:47. |