retagged by
1,022 views
0 votes
0 votes
#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?

retagged by

1 Answer

0 votes
0 votes
#include<stdio.h>

void fun(int *p,int *q) 
{ 
    p=q;                    /*3. p was pointing to i but now content of p are changed to address of q */
    *p=q;                   /*4. p is pointing to j so now content of j are changed with its own address */
} 
int i=0,j=1;                /*1. global variables i and j defined */
int main()

{ 
   fun(&i,&j);             /*2. function fun is called and addresses of i and j are passed as parameters */
   printf("%d%d",i,j);     /*5. 0 address-of-j-in-int */
}

Output : 0 address-of-j-in-int

https://ideone.com/CMYOAh

Related questions

0 votes
0 votes
1 answer
1
Psnjit asked Jan 12, 2019
1,160 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
0 answers
3
garvit_vijai asked Sep 2, 2018
709 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...
0 votes
0 votes
3 answers
4