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

Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

725


Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

857


Which programming language should I learn first?

697


Does improper inheritance have a potential to wreck a project?

776


What is the size of integer variable?

722






What is lambda in c++?

721


Explain terminate() function?

710


Can class objects be passed as function arguments?

738


What does it mean to declare a member function as virtual?

704


Can turbo c++ run c program?

766


What will happen if a pointer is deleted twice?

849


Is eclipse good for c++?

677


What is array in c++ pdf?

696


What's the order in which the objects in an array are destructed?

1045


What is the basic structure of c++ program?

715