Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by anand ( 8 years ago )
do
{
printf("1. insert element at first position \n");
printf("2. insert element at last position \n");
printf("3. insert element at position by user \n");
printf("4. display array \n");
scanf("%d",&ch);
switch(ch)
{
case 1 : first(a);
break;
case 2 : last(a);
break;
case 3 : pos(a);
break;
case 4 : display(a);
break;
default : printf("invalid choice \n");
break;
}
printf("do you want to continue(1/0) \n");
scanf("%d",&i);
}while(i==1);
}
void first(int a[])
{
int i;
printf("enter value \n");
scanf("%d",&i);
a[0]=i;
}
void last(int a[])
{
int i;
printf("enter value \n");
scanf("%d",&i);
a[4]=i;
}
void pos(int a[])
{
int i,n;
printf("enter position to insert \n");
scanf("%d",&n);
if(n>5)
printf("invalid position \n");
else
{
printf("enter value \n");
scanf("%d",&i);
a[n-1]=i;
}
}
void display(int a[])
{
int i;
for(i=0;i<5;i++)
{
printf("%d \t",a[i]);
}
}
Revise this Paste