1 Dimension Array
// there are many types of arrays like 1D, 2D, 3D etc
#include <stdio.h>
int main()
{
int a[5]={1,2,3,4,5}; //initialization of array of name "a" of size 5 with values
//accessing values of the array a[]
printf("%d",a[0]);
return 0;
}
//----------------------------------------------------
//using for loop for giving values to the array
/*#include <stdio.h>
int main()
{
int i;
int marks[5];
for(i=0;i<5;i++)
{
printf("enter value%d:",i);
scanf("%d",&marks[i]);
}
printf("\nthe values are\n");
for(i=0;i<5;i++)
{
printf("marks[%d]=%d\n",i,marks[i]);
}
return 0;
}
*/
Comments
Post a Comment