retagged by
359 views
1 votes
1 votes

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;

}

retagged by

1 Answer

0 votes
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

Related questions

3 votes
3 votes
3 answers
2
Laxman Ghanchi asked May 19, 2023
1,113 views
#include<stdio.h void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And H...
0 votes
0 votes
1 answer
3
Laxman Ghanchi asked May 19, 2023
658 views
#include<stdio.h>void print(int n){ printf("Hello "); if(n++ == 0) return ; print(n); n++;}int main(){ void print(); print(-4);}