Array Of C Programming In HINDI
What is Array in HINDI
Array are two types
1.One Dimensional Array
2.Multi Dimensional Array
Declaration of 1-D Array
- किसी भी Array का Dimension one हो उस Array को linear या one Dimensional Array कहते हैं|
- इसके elements को access करने के लिए एक single subscript का use करते हैं जो हमें row या column index को represent करता है|
- Syntax:- data type array name[size];
- data type:-यह Array में elements के type को denotes करता है|
- array name:- Name of the Array it must be a valid identifier.
- Size:- यहां पर number of element hold करते हैं|
Some example of Array declaration.
The individual elements of the above arrays are
- age[0],age[1],age[2] .................age[99]
- salary[0],salary[1],salary[2].....salary[14]
- grade[1],grade[2],grade[3]........grade[19]
int size =15;float salary [size]; /*valid*/int marks [size]; /*Not valid*/..............................................................................
Accessing Of 1-D Array Elements
- किसी array के elements को brackets में subscript के बाद array के नाम को specify करके access किया जा सकता है|
- In C the array subscript start from zero.
- माना कि किसी array की size 5 है तो उसका valid subscript 0,1,2,3,4 होगा
- Last वाला जो valid subscript है वह array के size से one कम होगा
- Last वाले valid subscript को array का upper bound और zero को lower bound कहते हैं|
Viz:- int [5];
/* size of array arr is 5,can hold five integer elements */
The elements of this array are-
array [0] , array [1] , array [2] , array [3] , array [4]
Note:-
- यहां पर zero lower bound है और 4 array की upper bound है|
- if i and j are integer variables then these are some valid subscripted array elements.
array [i] array [j] array [2*j] array [I+j] array [i++]
Viz:-if arr and sal are two array of size 5 and 10 respectively,then come and see these valid statements.
int arr [5];
float sal [10];
int i;
scanf("%d'',&arr [1]); /*input value into arr [1]*/
printf("%f",sal [3]);. /*print value of sal [3]*/
arr [4]=25; /*assign a value to arr [4]*/
arr [4] ++; b/*increment the value of arr [4] by 1*/
sal [5] +=200; /*Add 200 to sal [5]*/
i=2;
scanf("%f",&sal [i]); /*input value into sal [2]*/
Printf("%f",sal [i]); /*print value of sal[2]*/
Printf("%f",sal [i++]); /*print value of sal[2] and increment the value of i*/
Note:-if someone tries to access element beyond these subscripts,like arr[5],arr[10], the compiler will not show any error message but this may lead to run time errors.so it is the responsibility of programmer to provide array bounds checking wherever needed.
Processing Of 1-D Array
- Array के processing के लिए generally for loop का इस्तेमाल होता है|
- Loop variable का use subscript के स्थान पर किया जाता है|
- Loop variable का initial value zero लिया जाता है क्योंकि subscript zero से start होता है|
- The total number of passes in the loop will be equal to the number of elements in the array and in the array and each pass we will process one element.
- Reading value in arr
#include <stdio.h>
int main(void)
{
int arr [5] , i ;
for ( i=0; i<5; i++)
{
Printf(" Enter a value for arr[%d] : ",i );
scanf("%d", &arr [i] );
}
Printf(" The array elements are : \n ");
for ( i=0; i<5; i++)
Printf (" %d\t ", arr [i] );
Printf ( "\n" );
return 0;
}
OUTPUT:-
Enter a value for arr[0] : 23
Enter a value for arr[1] : 12
Enter a value for arr[2] : 15
Enter a value for arr[3] : 59
Enter a value for arr[4] : 21
The array elements are :
23 12 15 59 21
0 टिप्पणियाँ
अगर ऊपर दिए गए पाठ में आपको कोई Doubt है , तो Comment करे हमारी Team जल्द ही आपकी सहायता करेंगी।