One Dimensional array in C.
#include<stdio.h>
int main()
{
// printf("Hello World\n");
int marks[4];
for (int i = 0; i < 4; i++)
{
printf("Enter the value of %d element of the array\n", i);
scanf("%d", &marks[i]);
}
for (int i = 0; i < 4; i++)
{
printf("the value of %d element of the array is %d\n", i, marks[i]);
}
// int marks[4];
// marks[0] = 34;
// printf("marks of student 1 is %d\n", marks[0]);
// marks[0] = 5674;
// printf("marks of student 1 is %d\n", marks[0]);
// marks[0] = 5674;
// marks[1] = 5674;
// marks[2] = 5674;
// marks[3] = 5674;
// printf("marks of student 1 is %d\n", marks[0]);
return 0;
}
OUTPUT:
Enter the value of 0 element of the array
45
Enter the value of 1 element of the array
34
Enter the value of 2 element of the array
9
Enter the value of 3 element of the array
23
the value of 0 element of the array is 45
the value of 1 element of the array is 34
the value of 2 element of the array is 9
the value of 3 element of the array is 23
Comments
Post a Comment