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
a c code by using memory allocation for add ,multiply of sprase matrixes
What is the use of parallelize in spark?
With the help of using classes, write a program to add two numbers.
Explain how can I make sure that my program is the only one accessing a file?
What is pointer and structure in c?
Explain what is output redirection?
Why c is called top down?
What do mean by network ?
The statement, int(*x[]) () what does in indicate?
Explain what is gets() function?
What are the types of operators in c?
write a program to print data of 5 five students with structures?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
Explain how do you determine the length of a string value that was stored in a variable?
What is scanf () in c?