Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / prashant tyagi

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,item,n,a[10],loc,flg;
clrscr();
printf("Enter the limit N : ");
scanf("%d",&n);
if(n<=10)
{
for(i=1;i<=n;i++)
{
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}
printf("\nEnter the Location = ");
scanf("%d",&loc);
for(j=1;j<=n;j++)
{
if(loc==j)
{
flg=1;
printf("Insert = ");
scanf("%d",&item);
for(i=n;i>=loc;i--)
{
a[i+1]=a[i];
}
a[loc]=item;
}
}
if(flg==1)
{
n++;
}
else
{
printf("Location not Found");
}

printf("\nNew List\n");
for(i=1;i<=n;i++)
{
printf("\n%d",a[i]);
}
}
else
{
printf("Limit is not Valid ");
}
getch();
}

Is This Answer Correct ?    24 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1162


What is the method to save data in stack data structure type?

1080


How do I create a directory? How do I remove a directory (and its contents)?

1165


Why malloc is faster than calloc?

1060


If I have a char * variable pointing to the name of a function ..

1165


Which control loop is recommended if you have to execute set of statements for fixed number of times?

1341


What is the best way of making my program efficient?

1029


Explain what are the standard predefined macros?

1105


What is use of #include in c?

1159


What is a program flowchart and explain how does it help in writing a program?

1300


When would you use a pointer to a function?

1041


I came across some code that puts a (void) cast before each call to printf. Why?

1215


What is the difference between the expression “++a” and “a++”?

1229


Is swift based on c?

1099


What does void main () mean?

1230