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

What are friend classes? What are advantages of using friend classes?

0 Answers  


What is the identity function in c++? How is it useful?

0 Answers  


What is the use of the this pointer?

3 Answers  


Can we distribute function templates and class templates in object libraries?

0 Answers  


What is the difference between inline functions and macros?

5 Answers  


Explain the auto storage classes in c++.

0 Answers  


What is data abstraction? How is it different from data encapsulation?

0 Answers  


What do you understand by a pure virtual member function?

0 Answers  


When is the last time you coded in C/C++? What is the most lines of original C/C++ code you have personally written in one project? How confident are you in your ability to write C or C++ without a reference?

1 Answers   Microsoft,


Why #include is used?

0 Answers  


Define a pdb file.

0 Answers  


What are features of c++?

0 Answers  


Categories