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 is a pointer value and address in c?

636


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1520


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1122


What is a stream in c programming?

596


1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.

1661






Where local variables are stored in c?

556


What is the translation phases used in c language?

636


Which is better malloc or calloc?

651


What is c token?

611


What’s a signal? Explain what do I use signals for?

606


Do you know the purpose of 'register' keyword?

642


How to explain the final year project as a fresher please answer with sample project

469


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

1739


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1509


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1856