One Dimension Array Creating with User Define Size and its value also Displaying the Same
While Creating the one dimension array we have to follow the Algrothim :
Step 1: Declare The varibales i.e size , i.
Step 2: Take value in size variable and initialize the Array with the Given size
Step 3: Star a FOR LOOP from 0 to size Given by The User i.e. i<size
Step 4: Store The Values in array One By One
Step 5: End loop
Step 6: Now after Creating Lets Display , Start a Same Loop Again
Step 7: End loop
// writting the Program in C Language
// Creation of the 1d array
// Displaying the Created array
// Code Written by Shivam Dubey
#include<stdio.h>
int main()
{
// Declaring the variables
int size,i;
// Taking the size of the Array from User
printf("Enter The Size of the Array : ");
scanf("%d",&size);
printf("\n");
// initilizing the array of the size Given by the user
int arr[size];
for(i=0;i<size;i++)
{
printf("Enter The Number To store at %d : ",i);
scanf("%d",&arr[i]);
}
// Lets Display the Number of the Elements in Array
printf("\n \nThe Array is : ");
for(i=0;i<size;i++)
{
printf("%d\t",arr[i]);
}
return 0;
}