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
Write the syntax and purpose of a switch statement in C.
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
Do pointers need to be initialized?
How can you find out how much memory is available?
How many types of operators are there in c?
What is the difference between near, far and huge pointers?
What are integer variable, floating-point variable and character variable?
Can we access array using pointer in c language?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
Tell us the use of fflush() function in c language?
Can we declare a function inside a function in c?
Describe the modifier in c?
Explain what is the concatenation operator?
write a program for the normal snake games find in most of the mobiles.
What is wrong with this initialization?