→ This program will help you to learn how to implement an array in C.
#include<stdio.h>
int main()
{
int arr[5]; //declaration of an array with maximum five values
int i;
printf("Enter five numbers:");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]); //This line will take input in array from index zero to five i.e arr[0] to arr[4]
}
printf("Your numbers are:");
for(i=0;i<5;i++)
{
printf("%d ",arr[i]);
}
return 0;
}
Output: Enter five numbers:5
6
9
8
12
Your numbers are:5 6 9 8 12
#include<stdio.h>
int main()
{
int arr[5]; //declaration of an array with maximum five values
int i;
printf("Enter five numbers:");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]); //This line will take input in array from index zero to five i.e arr[0] to arr[4]
}
printf("Your numbers are:");
for(i=0;i<5;i++)
{
printf("%d ",arr[i]);
}
return 0;
}
Output: Enter five numbers:5
6
9
8
12
Your numbers are:5 6 9 8 12
Comments
Post a Comment