What are Array and pointer C programming language - Tech S K

Latest

Notes of Computers Technology Information,Latest Tech News, O Level Software Notes,RS CIT notes The notes of all the computer's exams are available here

Recent Posts

Translate

बुधवार, 13 जून 2018

What are Array and pointer C programming language


What are  Array and pointer  C programming language 

What are  Array and pointer  C programming language
What are  Array and pointer  C programming language

  • अर्रे और पॉइंटर सी प्रोग्रामिंग लैंग्वेज क्या हैं


आज Hindi के इस C programming language को आगे बढ़ाते हुए हम array को pointer के तरीके से जानेंगे.
हम नीचे दिए गए तरीके से array define करते हैं.
int A[10];
A[0] = 0; A[1] = 10; A[2] = 20; ...
इसमें A एक pointer ही होता है. A में array के पहली position वाले int का address store रहता है. A पहली position वाले int का address है, इसलिए A+1 दूसरी position वाले int का address हो जायेगा, A+2 तीसरी position वाले int का...
चूंकि A address है इसलिए *A का मान 0 आएगा(ऊपर A[0] = 0 है), *(A+1) का मान 10 आएगा, *(A+2) का मान 20 आएगा. ध्यान दे कि *(A)+1 और *(A+1) एक ही नहीं हैं. *(A)+1 का मतलब है A में जहाँ का address है उस position पर stored value पर 1 जोड़ना, जबकि *(A+1) का मतलब है A में जहाँ का address है उस position एक आगे वाली position पर stored value. इस तरह हमारे पास किसी array के किसी position(index) पर value को access करने के दो तरीके हैं. A[n] और *(A+n)
इसका एक example देखते हैं.
#include <stdio.h>

int main() {
  int A[] = {1,2,3,4};
  printf("[%d, %d, %d, %d]\n",A[0], A[1], A[2], A[3]);

  *A = 10;
  *(A+1) = 20;
  *(A+2) = 30;
  *(A+3) = 40;
  printf("[%d, %d, %d, %d]\n",A[0], A[1], A[2], A[3]);

  A[0] = 0; A[1] = 2; A[2] = 4; A[3] = 6;
  printf("[%d, %d, %d, %d]\n", *A, *(A+1), *(A+2), *(A+3));

  scanf("%d", A);
  return 0;
}
इसको run करके output का अध्ययन क

कोई टिप्पणी नहीं:

एक टिप्पणी भेजें

Friends, if you like this post then please share it on Facebook! Please tell through the comments that these posts will welcome you as well as your suggestions.