The Gateway to Computer Science Excellence
+1 vote
53 views

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 | 53 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 (481 points)
0
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,666 questions
56,158 answers
193,767 comments
93,754 users