write a program to insert an element at the specified
position in the given array in c language

Answer Posted / ajith.s uit adoor(2008-2010)

#include<stdio.h>
#include<conio.h>
void main()
{

int i,j,item,n,a[10],u,k;clrscr();

printf("enter the limit\n");
scanf("%d",&n);
if(n>=10)
{
printf("Array exceed limit .correct the limit value below
10 \n");
}
else
{

printf("enter the inserted element");
scanf("%d",&item);

printf("enter the position\n");
scanf("%d",&k);
if(k<=n||k<=10)
{
printf("enter the terms\n");
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
printf("inserted list\n");
for(i=1;i<=n;i++)
{
printf("%d\n",a[i]);
}
printf("inser list\n");
j=n;
while(j>=k)
{
a[j+1] =a[j];
j=j-1;
}
a[k]=item;

for(i=1;i<=n+1;i++)
{
printf("%d\n",a[i]);
}
}
else
{
printf("postion given in below limit not equal to \n");
}
}
getch();
}

Is This Answer Correct ?    12 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What header files do I need in order to define the standard library functions I use?

741


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

1832


What is the correct code to have following output in c using nested for loop?

823


What is identifier in c?

760


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3568


what are # pragma staments?

1808


By using C language input a date into it and if it is right?

798


What is the difference between functions getch() and getche()?

823


How do you generate random numbers in C?

901


Which built-in library function can be used to match a patter from the string?

989


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

859


What is c standard library?

898


Why & is used in scanf in c?

803


Can a void pointer point to a function?

761


What is the use of sizeof () in c?

765