ARRAYS
Name – BHAGWAN SAHAY JANGID
B.TECH FIRST YEAR (C.S.)
INTRODUCING ARRAYS :-
• An array is a collection of variables of
the same type that are referred to
through a common name.
Int num [3];
Num reference —: num[0]
num[1]
num[2]
• Data type array name [index];
• Example :-
• Int list [10];
• Char num [15];
• Float hat [20];
DECLARING ARRAY VARIABLES :-
CREATING ARRAYS :-
• Data type array _name [size];
• Example :
• Int num [10];
• Num [0] references the first element in the
array.
DIFFERENT TYPES OF ARRAYS :-
•ONE-DIMENSIONAL ARRAY
•TWO-DIMENSIONAL ARRAY
•MULTI-DIMENSIONAL ARRAY
ONE-DIMENSIONAL ARRAYS :-
•One dimensional array have only one subscript
under a common name.
•Syntax
•Data _type array_name [array_size];
•Example :-
•Int age [5]; ={2,3,4,5,6};
EXAMPLE PROGRAM :-
• # include <stdio.h>
• # include <conio.h>
• Int main ()
• {
int a[4];
int I ;
for (i=0; i<4 ; i++)
{
scanf(“%d”,& a[i]);
}
for (i=0 ; i<4; i++)
printf (“a[%d]=%d/n”,I, a[i]);
return 0;
}
TWO-DIMENSIONAL ARRAYS :-
•Two – dimensional array are those type of array.
Which has finite number of rows and finite number of
columns. 2D arrays are generally known as matrix.
•Data _type Array _name [row size ][columnsize];
EXAMPLE PROGRAM :-
• # include <stdio.h>
# include<conio.h>
into main()
{
int disp [3][4];
int I, j ;
for (i=0; i<=2; i++)
{
for (j=0; j<=4; j++)
}
printf (“Enter value for disp [%d][%d][%d]”,I, j);
scanf (“%d”,&disp [i] [ j]);
}
}
return 0;
}
MULTI-DIMENSIONAL ARRAYS :-
•An array have multiple subscript under a common
name.
•Syntax
•Type name [size][size]…..[size];
•Example :-
•Float a[2][6][8][4]…..[n];
EXAMPLE PROGRAM :-
int matrix [10][10];
{
for(i=0; i<10; i++)
for(j=0; j<10; j++)
{
matrix[i][ j] = i×j;
}
float mat [5][5];
THANK YOU

Array in c programming

  • 1.
    ARRAYS Name – BHAGWANSAHAY JANGID B.TECH FIRST YEAR (C.S.)
  • 2.
    INTRODUCING ARRAYS :- •An array is a collection of variables of the same type that are referred to through a common name. Int num [3]; Num reference —: num[0] num[1] num[2]
  • 3.
    • Data typearray name [index]; • Example :- • Int list [10]; • Char num [15]; • Float hat [20]; DECLARING ARRAY VARIABLES :-
  • 4.
    CREATING ARRAYS :- •Data type array _name [size]; • Example : • Int num [10]; • Num [0] references the first element in the array.
  • 5.
    DIFFERENT TYPES OFARRAYS :- •ONE-DIMENSIONAL ARRAY •TWO-DIMENSIONAL ARRAY •MULTI-DIMENSIONAL ARRAY
  • 6.
    ONE-DIMENSIONAL ARRAYS :- •Onedimensional array have only one subscript under a common name. •Syntax •Data _type array_name [array_size]; •Example :- •Int age [5]; ={2,3,4,5,6};
  • 7.
    EXAMPLE PROGRAM :- •# include <stdio.h> • # include <conio.h> • Int main () • { int a[4]; int I ; for (i=0; i<4 ; i++) { scanf(“%d”,& a[i]); } for (i=0 ; i<4; i++) printf (“a[%d]=%d/n”,I, a[i]); return 0; }
  • 8.
    TWO-DIMENSIONAL ARRAYS :- •Two– dimensional array are those type of array. Which has finite number of rows and finite number of columns. 2D arrays are generally known as matrix. •Data _type Array _name [row size ][columnsize];
  • 9.
    EXAMPLE PROGRAM :- •# include <stdio.h> # include<conio.h> into main() { int disp [3][4]; int I, j ; for (i=0; i<=2; i++) { for (j=0; j<=4; j++) } printf (“Enter value for disp [%d][%d][%d]”,I, j); scanf (“%d”,&disp [i] [ j]); } } return 0; }
  • 10.
    MULTI-DIMENSIONAL ARRAYS :- •Anarray have multiple subscript under a common name. •Syntax •Type name [size][size]…..[size]; •Example :- •Float a[2][6][8][4]…..[n];
  • 11.
    EXAMPLE PROGRAM :- intmatrix [10][10]; { for(i=0; i<10; i++) for(j=0; j<10; j++) { matrix[i][ j] = i×j; } float mat [5][5];
  • 12.