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
int i=10; printf("%d %d %d", i, i=20, i);
Explain what is the best way to comment out a section of code that contains comments?
which is an algorithm for sorting in a growing Lexicographic order
Why can’t constant values be used to define an array’s initial size?
How will you divide two numbers in a MACRO?
Why is it that not all header files are declared in every C program?
What is #include stdio h?
What is structure of c program?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
What are c identifiers?
What are linker error?
Can you tell me how to check whether a linked list is circular?
can any one tel me wt is the question pattern for NIC exam
What is the use of #define preprocessor in c?
Differentiate between static and dynamic modeling.