Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (anonymous):

:::::::::::::::::::::::::::: c program :::::::::::::::::::::::::: #include void main() { char ch=90; printf("%c",(char*)ch); } what would be the output & why ?

OpenStudy (anonymous):

output is "Z". 90 is Ascii value of "Z"(caps Z).

OpenStudy (anonymous):

Hope you got the answer.

OpenStudy (anonymous):

what is your expected output?

OpenStudy (anonymous):

i want to know why this is happening ???

OpenStudy (anonymous):

because you are defining %C . printf("%c",(char*)ch); OUTPUT WILL BE "Z" printf("%d",(char*)ch); OUTPUT will be "99"

OpenStudy (anonymous):

when char ch=90 executes then what gets stored in ch ?

OpenStudy (anonymous):

90

OpenStudy (anonymous):

and when printf("%c",(char*)ch); executes then what happens ?

OpenStudy (anonymous):

It prints it as character. because %c is indication of char value.

OpenStudy (anonymous):

Got the answer?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!