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 the cout in c++?
What are the sizes and ranges of the basic c++ data types?
Should a constructor be public or private?
What is data abstraction? How is it different from data encapsulation?
Who calls main function?
What is c++ prototype?
What is null c++?
Is set c++?
How compile and run c++ program in turbo c++?
Why do we use pointers in c++?
What does std mean in c++?
Describe Trees using C++ with an example.
Write is a binary search tree? Write an algo and tell complexity?
why is iostream::eof inside a loop condition considered wrong?
What is #include iostream in c++?