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


Please Help Members By Posting Answers For Below Questions

What is #include c++?

805


Keyword mean in declaration?

837


How many namespaces are there in c++?

807


Can we delete this pointer in c++?

991


How does list r; differs from list r();?

937


What are shallow and deep copy?

884


How do you remove an element from a set in c++?

865


Is it possible to provide default values while overloading a binary operator?

1024


Why struct is used in c++?

853


What is the difference between set and map in c++?

912


What is a responder chain?

830


What causes a runtime error c++?

858


What are static and dynamic type checking?

851


What are the rules about using an underscore in a c++ identifier?

878


What are c++ redistributables?

815