Create an array from the given inputs from the user using C

 

Hey guys once again welcome to the Decoders blog, I hope you all are doing well and today I'm present with another logic but this time with something different it is a C logic which will help us to print an array from the inputs given in by the user.

Now first of all what is an array : An array is collection of an ordered thing the inputs that can be stored in an array can either be an integer value an string value or a floating value.

For example 

int array[3] ={50,40,30}   //This an array with three integer elements

#include<stdio.h>
int main()
{
   int array[5];
   int n,i,j;
   printf("Enter the value of n utmost 5 values:");
   for(int i=1;i<=5;i++)
   {
       scanf("%d",&array[i]);
   }
   printf("The required array is:");
   for(int j=1;j<=5;j++)
   {
       printf("%d\n",array[j]);
   }
   return(0);

}  

Comments

Popular Posts