Q.1why is it that whatever i take the value of c, it has to be the last letter of the string?
Q.2the code works even if i replace char by int and %c by %d.why is it so?
Q.1 see my ques is
if char c='sjfbksj' output is j
if cahr c='azhsb' output is b
the last letter is always the output..y is it so?
Because a char can only hold 1 char obviously - so if you
try to give it a more than one char like you are trying to do - you will
only get the last one.
Q.2 so u mean int c='sgdrg' is a valid expression?
Also
if int c='a' output is 97
if int c='ab' output is 24930
why is it so?
in your case an int is 4 bytes long.
so if you say int c = 'ABCDEFG' - then the compiler will take the last 4
chars and put them into the integer.
So c will be (in hex) 0x44454647 - which is (decimal) 1145390663
BUT the compiler will give you a warning if you try to fit too big a value
into a particular variable. The warning will be something like: warning: character constant too long for its type