retagged by
652 views
2 votes
2 votes

Output of following program? 

#include<stdio.h>
int main() 
{ 
int *ptr; 
int x; 
ptr=&x; 
*ptr=0; 
printf("x=%d\n",x); 
printf("*ptr=%d\n",*ptr); 
*ptr+=5; 
printf("x=%d\n",x); 
printf("*ptr=%d\n",*ptr); 
(*ptr)++; 
printf(“x=%d\n",x); 
printf("*ptr=%d\n",*ptr); 
return 0; 
} 
  1. $x=0$ 
    $^*ptr=0$
    $x=5$ 
    $^*ptr=5$ 
    $x=6$ 
    $^*ptr=6$
  2. $x=$garbage value 
    $^*ptr=0$ 
    $x=$garbage value 
    $^*ptr=5$ 
    $x=$garbage value 
    $^*ptr=6$
  3. $x=0$ 
    $^*ptr=0$ 
    $x=5$ 
    $^*ptr=5$ 
    $x=$garbage value 
    $^*ptr=$garbage value
  4. $x=0$ 
    $^*ptr=0$ 
    $x=0$ 
    $^*ptr=0$ 
    $x=0$ 
    $^*ptr=0$
retagged by

1 Answer

1 votes
1 votes
A should be correct answer

 

 x=0
∗ptr=0
 x=5
∗ptr=5
 x=6
∗ptr=6
Answer:

Related questions

2 votes
2 votes
2 answers
2
admin asked Mar 30, 2020
1,027 views
Output of following program#include<stdio.h int main() { int i=5; printf("%d %d %d", i++,i++,i++); return 0; }$7\:6\:5$$5\:6\:7$$7\:7\:7$Compiler Dependent
3 votes
3 votes
1 answer
3
admin asked Mar 30, 2020
1,718 views
Output of following program? #include<stdio.h void dynamic(int s,...) { printf("%d",s); } int main() { dynamic(2,4,6,8); dynamic(3,6,9); return 0; }$2\:3$Compiler Error$4...
4 votes
4 votes
1 answer
4
admin asked Mar 30, 2020
2,029 views
Assume that size of an integer is $32$ bit. What is the output of following ANSI C program? #include<stdio.h struct st { int x; static int y; }; int main() { printf(%d",s...