/*Program to create an integer array and printing
elements of array*/
#include<conio.h>
void main()
{
int a[10],i;
clrscr();
printf("\nEnter 5 numbers:\n");
//inserting elements in array
for(i=0;i<5;i++)
{
printf("\nElement %d =>",i+1);
scanf("%d",&a[i]);
}
//printing elements in array
printf("\nElements in array:");
for(i=0;i<5;i++)
{
printf("\nElement %d =>",i+1);
printf("%d",a[i]);
}
getch();
}
-------------------------------------------------------------------------
Explanation:
--------------------------------------------------------------------------
In above program we have created an array of integer type with size(maximum 10) so our system
automatically index it as...
And we are inserting values using for loop with loop variable i=0 to i<5
that means 5 values 0, 1, 2, 3, 4.
Similarly after successful inserting values into array we are printing those values using again another
for loop.
--------------------------------------------------------------------------------------------------------------------------
elements of array*/
#include<conio.h>
void main()
{
int a[10],i;
clrscr();
printf("\nEnter 5 numbers:\n");
//inserting elements in array
for(i=0;i<5;i++)
{
printf("\nElement %d =>",i+1);
scanf("%d",&a[i]);
}
//printing elements in array
printf("\nElements in array:");
for(i=0;i<5;i++)
{
printf("\nElement %d =>",i+1);
printf("%d",a[i]);
}
getch();
}
-------------------------------------------------------------------------
Explanation:
--------------------------------------------------------------------------
In above program we have created an array of integer type with size(maximum 10) so our system
automatically index it as...
And we are inserting values using for loop with loop variable i=0 to i<5
that means 5 values 0, 1, 2, 3, 4.
Similarly after successful inserting values into array we are printing those values using again another
for loop.
--------------------------------------------------------------------------------------------------------------------------