#include<stdio.h>
int main(){
int
a[50],i,pos,size;
printf("\nEnter
size of the array: ");
scanf("%d",&size);
printf("\nEnter
%d elements in to the array: ",size);
for(i=0;i<size;i++)
scanf("%d",&a[i]);
printf("\nEnter
position where to delete: ");
scanf("%d",&pos);
i=0;
while(i!=pos-1)
i++;
while(i<10){
a[i]=a[i+1];
i++;
}
size--;
for(i=0;i<size;i++)
printf(" %d",a[i]);
return 0;
}
15 comments:
thanks a ton words cannot do justice to what u ve just provided me!!
Plz Specify the logic of while loop u used in programs
What will happen if same data is repeated in array. eg 56 98 56 87 23 OR
98 75 75 62 48 37
int arr[10]; //10 element int array
for(int i=0; i<10 ; i++)
{
if(arr[i] == key)
{
arr[i] = arr[i+1];
}
}
thanx the programs are really helpful for me n ma frnds
/* write a program to create an arraylist with string(add,remove)
operation.and value should be enter through keyboard.*/
#include
#include
void main( )
{
char a[50];
int size,pos;
clrscr();
printf("enter the size of the array\n");
scanf("%d",&size);
printf("Enter the elements of the array\n");
for(int i=0;i<size;i++)
scanf("%s",a[i]);
printf("enter the position to be removed");
scanf("%d",&pos);
for(i=pos-1;i<size;i++)
{
a[i]=a[i+1];
}
printf("\nthe element in %d position is removed",pos);
for(i=0;i<size-1;i++)
{
printf("\n%s",a[i]);
}
getch();
}
can we do this
printf("Enter element to delete");
scanf("%d",&x)
for(i=0;i<10;i++)
{
if (a[i]==x)
a[i]==a[i+1];
}
how can we write a program ,without getting the position from the user such that only the last element gets deleted ???
why u used while(i<10) here
i want to know delete an array element from the current position in c with explain please.
i want to knw delete the middle array elament in c with explanation pls
the same question of above all????
Is it possible to delete desired item from STACK ?
thnks very much
anyone explain the quick sort program which is given above plzzzzz
Post a Comment