!!!!
""""
ARRAY: Collection of similar type of data elements, in which
elements is unique and located in separated memory location.
- If multiple values are to be stored under the same variable name,
then arrays are used. In an array a single variable can be assigned
with number which acts as an index number or subscript.
- The value stored in the array in different memory location
indicates by the indexes.
There are two types of array variables
1. Single Dimensional Array
2. Multi Dimensional Array (2D, 3D etc.)
Single Dimensional array:
The single dimensional array variable is a variable in which the
values are stored in one dimensional. All the values are stored in
memory available in columns. Every element of the array can be
retrieved by indicating location number or index of the memory.
Declaration of array:
Data type <array name> [size];
Data type: it specified to store which type of data in array (int, char
etc).
Array Name: it is user defined variable.
Size: it specified how many data store in array. It must be unsigned
integer.
[ ]: Subscript operator.
Point to Remember:
1. Starting location of an array is zero and end location of an
array is size-1.
2. Total element store in array=size-1
3. Total memory required to store array=size*data type size.
4. It is subscript variable because the array elements are
identified by a number as index no.
!!!!
""""
Ex: int a [10];
Index no
0 1 3 4 5 6 7 8 9 10
Here start index=0
End index =size-1
Total elements= size=11
Total memory=size*data type=11*2=22 bytes.
1. C program to input data of an array
! " # $
% &
"
' ((
% &
' ((
%
)
*
2. C program to count the repetition of elements in
array
'
!!!!
""""
! " # $
% &
"
' ((
% &
" #
% &
' ((
''
((
*
%
)
*
3. C program to reverse of all element in an array
'
! " # $
% &
! "
' ((
% &
' + ' ++
! %
)
*
!!!!
""""
4. C program to find the sum of all element in an
array
'
! " # $
% &
! "
' ((
% &
' ((
' (
! '%
)
*
5. C program to find the largest element in an array
, - . )
! " - $/
% & -
! " % $/0 -
' - ((
% &
. )'
' - ((
. )
. )'
*
!!!!
""""
! 1 )) /% . )
*
6. C program to Display the odd position elements in
an array
'
! " # $
% &
"
' ((
% &
2 $
' ((
% 3''
! %
*
)
*
7. C code to search element in an array
' '
!!!!
""""
! " # $
% &
"
' ((
% &
" .
% &
45 6 54
' ((
''
'
'
*
*
''
" % '%
)
*
8. C code to show Ascending order of elements in an
array
7
! " # $
!!!!
""""
% &
"
' ((
% &
8 ) 9
' ((
7' ( 7 7((
7
'
' 7
7'
*
*
*
' ((
%
)
*
9. C code to show Descending order of elements in an
array
7
! " # $
% &
!!!!
""""
"
' ((
% &
8 ) 9
' ((
7' ( 7 7((
7
'
' 7
7'
*
*
*
' ((
%
)
*
10. C code to find largest and smallest number in an
array
, - . )
! " - $/
% & -
! " % $/ -
' - ((
% &
. )'
' - ((
!!!!
""""
. )
. )'
*
: ) /% . )
'
' - ((
'
*
6 /%
*
6 9 /
" - $/;
" ; $/3 < =
: ) /=
6 /
Two Dimensional arrays:
It is collection of rows and column data.
Syntax: to declaration array
Data type<array name>[row][column];
> ? @ @
> / $
A/8 $
@ @ / # -
B / ) C # + D +
E " /C # 5 D
E F $ C G /C # 5 D 56 -
!!!!
""""
"?/> @ @
3 @
3
3 @;
<= ,H I
E /@5@'I
E $/@5@53' =
11. C program to input data of an array
@ @ 7 '
" ?
% % & &
! " ?
' ((
7' 7 7((
% & 7
*
E E# 2 F ? >/!
' ((
7' 7 7((
% ! 7
*
!
*
!!!!
""""
)
*
12. C program to find the sum of all element in an 2D-
array
@ @ 7 '
" ?
% % & &
! " ?
' ((
7' 7 7((
% & 7
*
E E# 2 F ? >/!
' ((
7' 7 7((
% ! 7
*
!
*
' ((
7' 7 7((
' ( 7
*
!!!!
""""
! '%
)
*
@ Matrix addition in c language
@ @ . @ @ @ @ 7
" J ?+
' @ ((
7' 7 @ 7((
% & 7
! " 6 ?+
' @ ((
7' 7 @ 7((
% & . 7
! E J ? !
' @ ((
!
7' 7 @ 7((
% ! 7
*
! E 6 ? !
' @ ((
!
7' 7 @ 7((
% ! . 7
*
' @ ((
7' 7 @ 7((
7' 7(. 7
! E 8 # ? !
' @ ((
!!!!
""""
!
7' 7 @ 7((
% ! 7
*
*
14. SUBTRACTION OF TWO MATRICES USING C PROGRAM
@ @ . @ @ @ @ 7
" J ?+
' @ ((
7' 7 @ 7((
% & 7
! " 6 ?+
' @ ((
7' 7 @ 7((
% & . 7
! E J ? !
' @ ((
!
7' 7 @ 7((
% ! 7
*
! E 6 ? !
' @ ((
!
7' 7 @ 7((
% ! . 7
*
' @ ((
7' 7 @ 7((
!!!!
""""
7' 7+. 7
! E 6 . # ? !
' @ ((
!
7' 7 @ 7((
% ! 7
*
*
15. Matrix multiplication program in c language
, , . , , , , 7K '
! " # ?
% % & &
! " # ?
% % & &
! " J ?+
' ((
7' 7 7((
% & 7
! " 6 ?+
' ((
7' 7 7((
% & . 7
! E J ? !
' ((
!
7' 7 7((
% ! 7
*
!!!!
""""
*
! E 6 ? !
' ((
!
7' 7 7((
% ! . 7
*
*
' ((
7' 7 7((
7'
' (( 44 # ?
7' 7 7(( 44 ?
'
K' K K((
' ( K 5. K 7
7'
*
*
*
! E # ? !
' ((
!
7' 7 7((
% ! 7
*
*
*
!!!!
""""
16. C program for transpose of a matrix
. 7K'
! " # ?
% % & &
! " J ?+
' ((
7' 7 7((
% & 7
! E ? !
' ((
!
7' 7 7((
% ! 7
*
*
' ((
7' 7 7((
. 7'
' ((
7' 7 7((
. 7' 7
! % . 7
*
*
! ! E ? +
' ((
!
7' 7 7((
% ! . 7
*
!!!!
""""
*
*
17. Sum of diagonal elements of a matrix in c
7 '
! " # ?/
% % & &
! " ?/
' ((
7' 7 7((
% & 7
! E ? !
' ((
!
7' 7 7((
% ! 7
*
*
' ((
7' 7 7((
''7
' ( 7
*
*
! ! 6 ) ? /%
*

Array

  • 1.
    !!!! """" ARRAY: Collection ofsimilar type of data elements, in which elements is unique and located in separated memory location. - If multiple values are to be stored under the same variable name, then arrays are used. In an array a single variable can be assigned with number which acts as an index number or subscript. - The value stored in the array in different memory location indicates by the indexes. There are two types of array variables 1. Single Dimensional Array 2. Multi Dimensional Array (2D, 3D etc.) Single Dimensional array: The single dimensional array variable is a variable in which the values are stored in one dimensional. All the values are stored in memory available in columns. Every element of the array can be retrieved by indicating location number or index of the memory. Declaration of array: Data type <array name> [size]; Data type: it specified to store which type of data in array (int, char etc). Array Name: it is user defined variable. Size: it specified how many data store in array. It must be unsigned integer. [ ]: Subscript operator. Point to Remember: 1. Starting location of an array is zero and end location of an array is size-1. 2. Total element store in array=size-1 3. Total memory required to store array=size*data type size. 4. It is subscript variable because the array elements are identified by a number as index no.
  • 2.
    !!!! """" Ex: int a[10]; Index no 0 1 3 4 5 6 7 8 9 10 Here start index=0 End index =size-1 Total elements= size=11 Total memory=size*data type=11*2=22 bytes. 1. C program to input data of an array ! " # $ % & " ' (( % & ' (( % ) * 2. C program to count the repetition of elements in array '
  • 3.
    !!!! """" ! " #$ % & " ' (( % & " # % & ' (( '' (( * % ) * 3. C program to reverse of all element in an array ' ! " # $ % & ! " ' (( % & ' + ' ++ ! % ) *
  • 4.
    !!!! """" 4. C programto find the sum of all element in an array ' ! " # $ % & ! " ' (( % & ' (( ' ( ! '% ) * 5. C program to find the largest element in an array , - . ) ! " - $/ % & - ! " % $/0 - ' - (( % & . )' ' - (( . ) . )' *
  • 5.
    !!!! """" ! 1 ))/% . ) * 6. C program to Display the odd position elements in an array ' ! " # $ % & " ' (( % & 2 $ ' (( % 3'' ! % * ) * 7. C code to search element in an array ' '
  • 6.
    !!!! """" ! " #$ % & " ' (( % & " . % & 45 6 54 ' (( '' ' ' * * '' " % '% ) * 8. C code to show Ascending order of elements in an array 7 ! " # $
  • 7.
    !!!! """" % & " ' (( %& 8 ) 9 ' (( 7' ( 7 7(( 7 ' ' 7 7' * * * ' (( % ) * 9. C code to show Descending order of elements in an array 7 ! " # $ % &
  • 8.
    !!!! """" " ' (( % & 8) 9 ' (( 7' ( 7 7(( 7 ' ' 7 7' * * * ' (( % ) * 10. C code to find largest and smallest number in an array , - . ) ! " - $/ % & - ! " % $/ - ' - (( % & . )' ' - ((
  • 9.
    !!!! """" . ) . )' * :) /% . ) ' ' - (( ' * 6 /% * 6 9 / " - $/; " ; $/3 < = : ) /= 6 / Two Dimensional arrays: It is collection of rows and column data. Syntax: to declaration array Data type<array name>[row][column]; > ? @ @ > / $ A/8 $ @ @ / # - B / ) C # + D + E " /C # 5 D E F $ C G /C # 5 D 56 -
  • 10.
    !!!! """" "?/> @ @ 3@ 3 3 @; <= ,H I E /@5@'I E $/@5@53' = 11. C program to input data of an array @ @ 7 ' " ? % % & & ! " ? ' (( 7' 7 7(( % & 7 * E E# 2 F ? >/! ' (( 7' 7 7(( % ! 7 * ! *
  • 11.
    !!!! """" ) * 12. C programto find the sum of all element in an 2D- array @ @ 7 ' " ? % % & & ! " ? ' (( 7' 7 7(( % & 7 * E E# 2 F ? >/! ' (( 7' 7 7(( % ! 7 * ! * ' (( 7' 7 7(( ' ( 7 *
  • 12.
    !!!! """" ! '% ) * @ Matrixaddition in c language @ @ . @ @ @ @ 7 " J ?+ ' @ (( 7' 7 @ 7(( % & 7 ! " 6 ?+ ' @ (( 7' 7 @ 7(( % & . 7 ! E J ? ! ' @ (( ! 7' 7 @ 7(( % ! 7 * ! E 6 ? ! ' @ (( ! 7' 7 @ 7(( % ! . 7 * ' @ (( 7' 7 @ 7(( 7' 7(. 7 ! E 8 # ? ! ' @ ((
  • 13.
    !!!! """" ! 7' 7 @7(( % ! 7 * * 14. SUBTRACTION OF TWO MATRICES USING C PROGRAM @ @ . @ @ @ @ 7 " J ?+ ' @ (( 7' 7 @ 7(( % & 7 ! " 6 ?+ ' @ (( 7' 7 @ 7(( % & . 7 ! E J ? ! ' @ (( ! 7' 7 @ 7(( % ! 7 * ! E 6 ? ! ' @ (( ! 7' 7 @ 7(( % ! . 7 * ' @ (( 7' 7 @ 7((
  • 14.
    !!!! """" 7' 7+. 7 !E 6 . # ? ! ' @ (( ! 7' 7 @ 7(( % ! 7 * * 15. Matrix multiplication program in c language , , . , , , , 7K ' ! " # ? % % & & ! " # ? % % & & ! " J ?+ ' (( 7' 7 7(( % & 7 ! " 6 ?+ ' (( 7' 7 7(( % & . 7 ! E J ? ! ' (( ! 7' 7 7(( % ! 7 *
  • 15.
    !!!! """" * ! E 6? ! ' (( ! 7' 7 7(( % ! . 7 * * ' (( 7' 7 7(( 7' ' (( 44 # ? 7' 7 7(( 44 ? ' K' K K(( ' ( K 5. K 7 7' * * * ! E # ? ! ' (( ! 7' 7 7(( % ! 7 * * *
  • 16.
    !!!! """" 16. C programfor transpose of a matrix . 7K' ! " # ? % % & & ! " J ?+ ' (( 7' 7 7(( % & 7 ! E ? ! ' (( ! 7' 7 7(( % ! 7 * * ' (( 7' 7 7(( . 7' ' (( 7' 7 7(( . 7' 7 ! % . 7 * * ! ! E ? + ' (( ! 7' 7 7(( % ! . 7 *
  • 17.
    !!!! """" * * 17. Sum ofdiagonal elements of a matrix in c 7 ' ! " # ?/ % % & & ! " ?/ ' (( 7' 7 7(( % & 7 ! E ? ! ' (( ! 7' 7 7(( % ! 7 * * ' (( 7' 7 7(( ''7 ' ( 7 * * ! ! 6 ) ? /% *