filmov
tv
One Dimensional Arrays in C - C Programming Tutorial 69
Показать описание
Notes for You:: One Dimensional Arrays in C - C Programming Tutorial 69
- While accessing each element in an array; if it requires only one indexor subscriptsuch an array is called 1-dimensional array.
Example: arrayName[index]
Note:
- 1D array is used to store list of values arranged in either a row or a column
Declaring a one dimensional array in C:
Syntax:
data_typearrayName[size];
Example:
int numbers[5]; // numbers is an array; which can hold 5 integer values
Note:
- implicit pointers associated with one dimensional arrays in C.
- arrayName is implicitly a pointer to the first element in the array
- i.e. arrayName returns address of the first element in the array.
- &arrayName is implicitly a pointer to the whole array.
- i.e.&arrayName returns beginning address of the whole array
Getting a value of an array element:
- We can get a value of an array element by its index.
Syntax:
arrayName[index]
Example:
printf(“%d\n”,numbers[0]); // garbage integer value
Declaring and initializing a one dimensional array:
Syntax:
data_typearrayName[size] = {list of values separated by comma};
Example:
int numbers[5] = {0, 0, 0, 0, 0};
Setting new value to an array element:
- We can set a new value to an array element using assignment operator.
Syntax:
arrayName[index]=newvalue;
Example:
numbers[0]=10;
printf(“%d\n”,numbers[0]); // 10
=========================================
Follow the link for next video:
Follow the link for previous video:
=========================================
C Programming Tutorials Playlist:
=========================================
Watch My Other Useful Tutorials:-
Computer Programming Fundamentals Playlist:-
C Practical LAB Exercises Playlist:-
C++ Tutorials Playlist:
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #CProgramming #CProgrammingTutorial
- While accessing each element in an array; if it requires only one indexor subscriptsuch an array is called 1-dimensional array.
Example: arrayName[index]
Note:
- 1D array is used to store list of values arranged in either a row or a column
Declaring a one dimensional array in C:
Syntax:
data_typearrayName[size];
Example:
int numbers[5]; // numbers is an array; which can hold 5 integer values
Note:
- implicit pointers associated with one dimensional arrays in C.
- arrayName is implicitly a pointer to the first element in the array
- i.e. arrayName returns address of the first element in the array.
- &arrayName is implicitly a pointer to the whole array.
- i.e.&arrayName returns beginning address of the whole array
Getting a value of an array element:
- We can get a value of an array element by its index.
Syntax:
arrayName[index]
Example:
printf(“%d\n”,numbers[0]); // garbage integer value
Declaring and initializing a one dimensional array:
Syntax:
data_typearrayName[size] = {list of values separated by comma};
Example:
int numbers[5] = {0, 0, 0, 0, 0};
Setting new value to an array element:
- We can set a new value to an array element using assignment operator.
Syntax:
arrayName[index]=newvalue;
Example:
numbers[0]=10;
printf(“%d\n”,numbers[0]); // 10
=========================================
Follow the link for next video:
Follow the link for previous video:
=========================================
C Programming Tutorials Playlist:
=========================================
Watch My Other Useful Tutorials:-
Computer Programming Fundamentals Playlist:-
C Practical LAB Exercises Playlist:-
C++ Tutorials Playlist:
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #CProgramming #CProgrammingTutorial
Комментарии