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
How to retrieve images in sql server database through vb.net?
What is the significance of delegates?
What do you understand by vb.net?
What do you mean by option strict on?
What is the difference between convert.tostring and i.tostring method?
What is the difference between manifest and metadata?
Explain the advantages of migrating to vb.net?
Name some of the features present in vb 2005?
What is vb.net used for?
What is strong typing and weak typing?
What is the advantages of VB.NET?
Can you please explain the difference between c# and vb.net?
Explain the difference between value and reference types?
Which is the tool which can convert visual basic old version to .net compatibility version?
Explain how can we remove handlers at run time?