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 is c++ iterator?

0 Answers  


Explain about Virtual Function in C++?

0 Answers  


Write a program to find the Factorial of a number

0 Answers  


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

0 Answers  


What is istream c++?

0 Answers  






What is the difference between while and do while loop? Explain with examples.

0 Answers  


What is a rooted hierarchy?

0 Answers  


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

0 Answers  


What is function overriding?

1 Answers  


what is the use of void main() in C++ language?

0 Answers  


Evaluate: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); a) 10 b) 11 c) 1

4 Answers   Quark,


What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass

0 Answers  


Categories