Free Online Tutorials ==>> Machine Learning || Python Programming || DBMS || OOPs using C++ || DSA || Java Programming || Linux/Unix || C Programming
Go to your University || Python Lab || DSA Lab || AI & Machine Learning Lab || Linux Lab || OOPs Lab || DBMS Lab || JAVA Lab ||| Free Online Tutorials ||| 
companies for Campus Placement || Logical Reasoning || Quantitative Aptitude || General English || Technical-MCQ and Interview Questions || HR Interview Questions
0 like 0 dislike
33 views

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.8k points)
 
Best answer
#include <stdio.h>

#define SIZE (10)

int main()

{    

size_t i = 0;    

int *p = NULL;    

int a[SIZE];       /* Setting up the values to be i*i */    

for(i = 0; i < SIZE; ++i)    

{        

a[i] = i * i;    

}       /* Reading the values using pointers */    

for(p = a; p < a + SIZE; ++p)    

{        

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

}

return 0;

}

Here, in the initialization of p in the first for loop condition, the array a decays to a pointer to its first element, as it would in almost all places where such an array variable is used.

Then, the ++p performs pointer arithmetic on the pointer p and walks one by one through the elements of the

array, and refers to them by dereferencing them with *p.
  Realize your learning potential with courses starting at ₹ 420
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Online Free Training:  MACHINE LEARNINGPython Programming | Database Management System(DBMS) | Object Oriented Programming(OOPs) using C++ | Data Structures and Algorithms(DSA) | Java Programming | Linux/Unix | C Programming
Exams: List of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG) | JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...