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

total amount of milk produced each morning and then calculates and outputs the number of cartons needed for this milk , the cost of producing the milk and the profit from producing this milk.

2324


What is abstract keyword in c++?

838


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

845


What is microsoft c++ redistributable?

804


Define friend function.

797


What is a class template?

825


What is c++ array?

795


What do you mean by translation unit in c++?

981


How do I run c++?

809


What is c++ hiding?

898


Explain the advantages of using friend classes.

857


What is the difference between while and do while loop?

870


Is c++ slower than c?

816


What is the difference between the parameter to a template and the parameter to a function?

916


Explain how to initialize a const data member.

864