The Gateway to Computer Science Excellence
+1 vote

what is the output???? and

how it internally converted to int when we are printing with %d format specifier??

when i run in my ide i got 50 as output and i donn’t know how it came?

can anyone explain how 50 came

#include <stdio.h>

int main()


    char a = '12';


    printf("%d", a);


    return 0;


in Programming by
retagged by | 66 views

1 Answer

0 votes
it prints the ascii value of last digit.

char a = '12';

In location a first ascii value of 1 will be stored and then it will be over written by ascii value of 2.

Now at location a  ascii value of 2 is present.

If we try to print it :  %d will return 50 which is ascii value of 2

                               %c will print 2
thank you...!

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,215 questions
59,981 answers
94,636 users