Enter n no. of element and delete value from desire position



Enter n no. of element and delete value from desire position..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int n,pos,i,a[20];
printf("\nEnter how many elements are there in an array ");
scanf("%d",&n);
printf("\nEntert the elements ");
for(i=0;i<n;i++)
{

scanf("%d",&a[i]);
}
printf("\nEnter the position from where u want to delete
an item ");
scanf("%d",&pos);
pos=pos-1;
for(i=0;i<n;i++)
{
if((i==pos)&&(i!=n-1))
{
i=i+1;
}

if((i==pos)&&(i==n-1))
break;
printf("%d\n",a[i]);

}
getch();
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ General Interview Questions

Can we declare a base-class destructor as virtual?

0 Answers  


Why was c++ created?

0 Answers  


How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)

2 Answers  


If dog is a friend of boy, is boy a friend of dog?

0 Answers  


What is "map" in STL?

2 Answers  






Can inline functions have a recursion? Give the reason?

3 Answers  


Will the inline function be compiled as the inline function always? Justify.

1 Answers  


How would you use the functions sin(), pow(), sqrt()?

0 Answers  


What are the benefits of oop in c++?

0 Answers  


What happens when you make call 'delete this;'?

0 Answers  


Is the declaration of a class its interface or its implementation?

0 Answers  


What do you mean by “this” pointer?

0 Answers  


Categories