one dimensional array:
An array which has only one subscript is known as one dimensional array i.e) int a[5].
Syntax
data_type varname[size];
Declaration of an array program :
In C programming, programmers can also initialize the array variable without mentioning the size of an array. The compiler will automatically deduct the size of an array.
declaration-1
int student[5] = {89, 76, 98, 91, 84};
declaration-2
int student[] = {89, 76, 98, 91, 84};
Program:
#include <stdio.h>
int main()
{
int s[5] = {89, 76, 98, 91, 84}, i;
printf("\n---Students marks details--- ");
for(i = 0; i < 5; i++)
{
printf("\ns%d = %d ", i + 1, s[i]);
}
return 0;
}
output;
An array which has only one subscript is known as one dimensional array i.e) int a[5].
Syntax
data_type varname[size];
Declaration of an array program :
In C programming, programmers can also initialize the array variable without mentioning the size of an array. The compiler will automatically deduct the size of an array.
declaration-1
int student[5] = {89, 76, 98, 91, 84};
declaration-2
int student[] = {89, 76, 98, 91, 84};
Program:
#include <stdio.h>
int main()
{
int s[5] = {89, 76, 98, 91, 84}, i;
printf("\n---Students marks details--- ");
for(i = 0; i < 5; i++)
{
printf("\ns%d = %d ", i + 1, s[i]);
}
return 0;
}
output;
No comments:
Post a Comment