Skip to main content

1-D array example 2

#include<stdio.h>
int main()
{
    int marks[5]; //declare without initialization
    for (int i = 0i <5i++)
    {
        printf("Enter the %d of the valve of array\n",i);
        scanf("%d",&marks[i]);
    }
    for (int i = 0i < 5i++)
    {
        printf("The value of %d value of the array is %d\n",i,marks[i]);
    }
    
    return 0;
}

//Or we can also do like this
#include<stdio.h>
int main()
{
    int marks[5]={95,97,91,93,99}; // declare with initialization
    
    for (int i = 0i < 5i++)
    {
        printf("The value of %d value of the array is %d\n",i,marks[i]);
    }
    
    return 0;
}

Comments