Enter n no. of element and delete value from desire position
Answer Posted / 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 View All Answers
What is srand c++?
Explain what happens when a pointer is deleted twice?
Why main function is special in c++?
What's the best free c++ profiler for windows?
Can we make copy constructor private in c++?
Describe linked list using C++ with an example.
Define macro.
What is function prototyping? What are its advantages?
What does asterisk mean in c++?
When should I use unitbuf flag?
What is the best way to declare and define global variables?
How do you declare a set in c++?
What is using namespace std in c++?
Does c++ have foreach?
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;