Program of TRAVERSE of array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[30],n,i;
void traverse(int [],int);
clrscr();
printf("Enter the size of array");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the element for a[%d]",i);
scanf("%d",&a[i]);
}
traverse(a,n);
getch();
}
void traverse(int a[],int n)
{
int i;
for(i=0;i<n;i++)
printf("\na[%d]= %d",i,a[i]);
}
WAP to insert an element at the begning of array
#include<stdio.h>
#include<conio.h>
void main()
{
int a[30],n,i,v;
void insert_beg(int [],int,int);
clrscr();
printf("Enter the size of array");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the element for a[%d]",i);
scanf("%d",&a[i]);
}
printf("\nEnter the value to be inserted");
scanf("%d",&v);
insert_beg(a,n,v);
getch();
}
void insert_beg(int a[],int n,int v)
{
int i;
for(i=n-1;i>=0;i--)
a[i+1]=a[i];
a[0]=v;
n++;
for(i=0;i<n;i++)
printf("\na[%d]= %d",i,a[i]);
}