#include<stdio.h>
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
return 0;
}

Output: 20
can anyone explain how came the output is 20



#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; ..

Answer / Girish Singh Gobari

The output is 20 because the integer pointer (ptr) is assigned a new memory address that contains the value 20. When the printf function is called with i as an argument, it displays the value stored at the address i points to, which is now 20.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Software Interview Questions

1 Answers   CAT,


What is the purpose of clrscr () printf () and getch ()?

1 Answers  


write a program to create a sparse matrix using dynamic memory allocation.

1 Answers  


Write a program to generate prime factors of a given integer?

9 Answers   Microsoft,


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

1 Answers  


What are static variables, and where are they stored?

2 Answers  


Explain data types & how many data types supported by c?

1 Answers  


What is define directive?

1 Answers  


please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }

3 Answers  


What is meant by high-order and low-order bytes?

1 Answers  


Write a program to compare two strings without using the strcmp() function

42 Answers   Accenture, Arba Minch University,


what is pointer ? what is the use of pointer?

6 Answers   Infosys,


Categories