1,723 views
1 votes
1 votes
#include <stdio.h>

int main()
{
    int i =258;
    int *iptr = &i;
    printf("%d%d",*((char*)iptr),*((char*)iptr+1));

    return 0;
}

(a)2,1 (b)2,5

(c)1, 2  (d)5,2

I am getting  (a) as output

sh-4.2$ gcc -o main *.c                                                                                                                                

sh-4.2$ main                                                                                                                                           

21

       

Can anybody explain that how we got that?

Thanks :)                                                                                                                                     

           

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
Psnjit asked Jan 12, 2019
1,157 views
main(){unsigned int i= 255;char *p= &i;int j= *p;printf("%d\n", j);unsigned int k= *p;printf("%d", k);} Both the outputs are -1. I have even tried with - int i = 255(3rd ...
0 votes
0 votes
1 answer
2
Mr khan 3 asked Nov 3, 2018
1,009 views
#include<stdio.h void fun(int *p,int *q) { p=q; *p=q; } int i=0,j=1; int main() { fun(&i,&j); printf("%d%d",i,j); }What will be the output of i and j in 16-bit C Compiler...
0 votes
0 votes
0 answers
4
garvit_vijai asked Sep 2, 2018
703 views
Please explain the output for the following program: #include<stdio.h>int main() { int i = 100; int *a = &i; float *f = (float *)a; (*f)++; pri...