Click here to Skip to main content
13,449,902 members (55,689 online)
Rate this:
Please Sign up or sign in to vote.
See more:
char x;
int y;

plzz give me proper explanation for the Output.

What I have tried:

on running this code i am getting output as

but why????????
Posted 3-Jan-18 4:55am
Updated 3-Jan-18 8:43am
‭011111100010‬ 3-Jan-18 11:15am
Which line of output do you have a question about? The third one should be real obvious.
CHill60 4-Jan-18 9:05am
By the way, people will treat you and your questions more seriously if you stop using text-speak (it's "please" not "plzz"). Not everyone has English as a first language and your use of slang is alienating you from potential help.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Because that's what you asked for.
See here: ASCII table[^]

The "%c" specifier says "treat the input value as a character and print that". Look at the table, and find "100" under the "Dec" column - it's a lower case "d". Now look for "125" in the same column and it's "}".
So you asked it to print your value as a character, and that is exactly what it did.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You have, when looked at along with your previous question, a very great need to study the C data types. C, perhaps more than any other language you're likely to use, will let you do foolish things because you asked it to do them.

C was written, originally, to write operating systems. That means it is allowed to do pretty much anything you ask it to do - including mixing up types. It will, depending upon your compiler, let these go without any errors or warnings. Most of the time is flags problems for you, but some things are reasonably requests . . . even if they're not at all what you wanted to do.

I have deliberately, for example, taken a string of characters and interpreted them as integers.

SO PLEASE study C data types.
Amit Razdan 4-Jan-18 9:45am
thank u sir....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02-2016 | 2.8.180318.3 | Last Updated 3 Jan 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100