Thursday, 2 May 2013

PROGRAM TO INSERT AN ELEMENT IN THE REQUIRED POSITION IN AN ARRAY

#include<stdio.h>
void main()
{
int a[11],c,k,i;
printf("Enter the elements of the array:");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("Enter the position where you want to insert an element:");
scanf("%d",&k);
printf("Enter the element you want to insert:");
scanf("%d",&c);
for(i=10;i>=k;i--)
{
a[i]=a[i-1];
}
a[k-1]=c;
printf("The new array is \n");
for(i=0;i<11;i++)
{
printf("%d  ",a[i]);
}
getch();
}

2 comments:

  1. Good Sattu... way to go
    :)
    Will be interesting if you solve some cute [interesting] stuff too...

    ReplyDelete