Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

pointer in c

+4 votes
asked Aug 8, 2018 by anonymous
Assuming all header files are included what is the output?

.......................................................................................................

void main()

{

int*p;

*p=1;

printf("%d",*p);

}

..................................................................

why the output of above lines is 1??????????????

18 Answers

0 votes
answered Sep 7, 2018 by pintusingh293 (140 points)
Because *p address is assigns value of 1..so above lines output is 1..
0 votes
answered Jul 18, 2019 by ammulu

void main()

{

 int var;

void *ptr=&var;

*ptr=5;

printf("%d\n%d\n",var,*ptr);

}

0 votes
answered Jul 18, 2019 by amms
segmenation fault
0 votes
answered Jul 21, 2019 by Vibhu Shukla
its a simple programing logic, if u had not used pionters then also the output was comimg to be 1;
0 votes
answered Jul 21, 2019 by sahdev (180 points)
```c

int main(void)

{

    int a, *p;

    a = 1;

    *p = &a;

    printf("%d\n%d\n", a, p);

    return 0;

}
0 votes
answered Jul 26, 2019 by kritika
because estreek p has taken value 1
0 votes
answered Jul 27, 2019 by anonymous

Because you take pointer variable as a integer as *P (which stores the data present in the address), and assign a value as  *P=1;

 so when you print the *P it gives the result as 1;

0 votes
answered Jul 27, 2019 by Shwetha Ginivalad (140 points)
1

because here we are putting value to the pointer p by the statement  

   *p=1;
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...