Wednesday, 6 June 2018

Poiinter

Pointer Arithmetic 

Pointer Arithmetic में आप pointer के अंदर रखे हुए address की value  को add ,subtraction,multiplication  and  divide  कर सकते हो |

Arithmetic operation को जब हम pointer में use करते है तब  दोनों value के data type ,  same भी होइ सकते है औरdifferent  भी |
For  ex .  

1.  #include<stdio.h>
       int main()
       {
          int i=5,j=10,*ip,*jp;
           ip=&i,jp=&j;
           printf("%d", *ip + *jp);
           return 0;
        }

Output : 15 

   or 

#include<stdio.h>
int main()
{
 int i=5,*ip;
 float j=10.50 ,*jp ;
 ip=&i,jp=&j;
 printf("%f", *ip + *jp);
 return 0;

 }

Output : 15. 50000 

2.    #include<stdio.h>
       int main()
       {
          int i=5,j=10,*ip,*jp;
           ip=&i,jp=&j;
           printf("%d", *ip + *jp);
           return 0;
        }

Output :-5 


3.    #include<stdio.h>
       int main()
       {
          int i=5,j=10,*ip,*jp;
           ip=&i,jp=&j;
           printf("%d", *ip * *jp);
           return 0;
        }

Output :50 


4.    #include<stdio.h>
       int main()
       {
          int i=5,j=10,*ip,*jp;
           ip=&i,jp=&j;
           printf("%d", *ip + *jp);
           return 0;
        }

Output : 0 



पर pointer क ander रखे हुए address को आप सिर्फ



True/False:
1.  Are the expression *ptr++ and ++*ptr are same?

2.  void (*ptr)(int); ptr is ptr is pointer to int that converts its type to void.

question
meaning og n=*&q;

No comments:

Post a Comment

ch-12 File Handling

Mcq 1. What does fp point to in the program?   #include<stdio.h> int main() {   FILE *fp;   fp=fopen("trial",...