Write a program that accepts an array of numbers, and two
numbers (an element and a
position in the array) and inserts the given element into
nth position of the array.

Answer Posted / surabhi

void main()
{
int x[6],item,pos,i,n;
printf("\n enter no of elements to be inserted:");
scanf("\n %d",&n);
for(i=0;i<n;i++)
{
printf("\n enter elements:");
scanf("%d",&x[i]);
}
printf("\n enter item to be inserted:");
scanf("%d",&item);
printf("\n enter position:");
scanf("%d",&pos);
for(i=n;i<=pos-1;i--)
{
x[i+1]=x[i];
}
x[pos-1]=item;
printf("\n elements after insertion:");
for(i=0;i<=n;i++)
{
printf("\n %d",x[i]);
}
getch();
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are option strict and option explicit?

783


write a program to develop a graphic user interface application of marks book with students names and their names.the program should show the following options main menu,add student details,display student details,maximum mark and minimum mark.

1169


What is difference between inline and code behind?

513


How do you retrieve the customized properties of a .net application from xml .config file?

510


What is the Advantage of vb.net over vb

559






What do you mean by Redim in VB.NET?

664


What is a literal control?

575


Define naming convention?

616


What is the difference between static or dynamic assemblies?

554


What is the source code for display the picture in button click event?

697


hello thank you for replying to my question regarding adding barcode fonts in vb.net project. I have downloaded a free font and added in my vb.net project but now i dont know how to use that i need to generate barcodes can any body help me how to use those fonts these are font3of9 .i need a small code to use these fonts to generate barcode thank u!

1567


What is the difference between c# and vb.net?

554


Why do we use ansi keyword?

560


What do you mean by serialization?

526


How to achieve Polymorphism in VB.Net?

612