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 runtime errors c++?

0 Answers  


Which bitwise operator is used to check whether a particular bit is on or off?

0 Answers  


What is the basic structure of a c++ program?

0 Answers  


What is an undefined behavior and sequence points

0 Answers  


What is size of empty class object

5 Answers   CA,






What are the main differences between C and C++?

1 Answers  


what is the size of this class class size { public: char data1; double d; int data2; char data3; double data4; short data5; }; please explain the padding for these double variables.

9 Answers  


What is private public protected in c++?

0 Answers  


What are C++ inline functions?

1 Answers  


What is an ABC: an "Abstract Base Class"?

1 Answers  


Is c++ vector dynamic?

0 Answers  


How would you use qsort() function to sort an array of structures?

0 Answers  


Categories