The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+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 (171 points)
retagged by | 52 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
by (465 points)
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
50,376 questions
55,840 answers
91,396 users