Pages

Tuesday 5 March 2019

Program to illustrate pointer arithmetic

Program to illustrate pointer arithmetic without increment operator

#include <stdio.h>
void main()
{
   int a[5]={10,20,30,40,50};
   int *p;
   int *q;
   p=&a[1];
   q=&a[4];
   printf("\n value is  %d",(*p + *q));  
}

output:


Program to illustrate pointer arithmetic with increment operator

#include <stdio.h>
void main()
{
   int a[5]={10,20,30,40,50};
   int *p;
   int *q;
   p=&a[1];
   q=&a[4];
   p++;
   printf("\n value is  %d",(*p + *q));
   q++;
   printf("\n value is  %d",(*p + *q));
}
output:

 

No comments:

Post a Comment

Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...