C
Programming and Technical
Programming
Program
#include
int main()
{
void *ptr1, *ptr2;
int x,y;
x = 100;
y = 200;
ptr1 = &x;
ptr2 = &y;
printf("%d", *(int*)ptr1);
printf("n%d", *(int*)ptr2);
}
Read Solution (Total 15)
-
- ans: 100n200
- 10 years agoHelpfull: Yes(4) No(2)
- Error . because void *ptr1,*ptr1 , there is no datatype for the pointers
- 10 years agoHelpfull: Yes(4) No(4)
- ans 100n200 bcoz void pointer is type casted to int..
- 10 years agoHelpfull: Yes(3) No(0)
- 100n200
bcoz typecasting into int
- 10 years agoHelpfull: Yes(2) No(0)
- integer cannot be casted to an void type
- 10 years agoHelpfull: Yes(2) No(1)
- output:100n200
- 10 years agoHelpfull: Yes(1) No(0)
- first print 100
and then print 200 - 10 years agoHelpfull: Yes(1) No(0)
- Error because pointers are declared with return type there is no return type for pointers
- 10 years agoHelpfull: Yes(1) No(2)
- 100 n 200 becauze *ptr get addresss and **ptr retrive value and here it casted pointer into integer val therefore answer is as it is.
Ex.assume 100 is stored at loc 1000
200 is stored at loc 1002
then ptr1=1000 nd ptr2=1002
it display address 1000 at value 100 and 1002 at value 200
- 10 years agoHelpfull: Yes(1) No(1)
- since ptr1 and ptr2 are void pointers they can be typecasted to any other datatype
100
200 - 10 years agoHelpfull: Yes(0) No(0)
- 100
200
here for accessing the data from the address stored in void pointers we are using type casting. - 10 years agoHelpfull: Yes(0) No(0)
- 100n200;by the default it will take int datatype
- 10 years agoHelpfull: Yes(0) No(0)
- ans is 100200
- 10 years agoHelpfull: Yes(0) No(0)
- ans is 100 200
- 10 years agoHelpfull: Yes(0) No(0)
- Why is the n comming in middle?
- 9 years agoHelpfull: Yes(0) No(0)
C Other Question