how to delete an element in an array

Answers were Sorted based on User's Feedback



how to delete an element in an array ..

Answer / aneesh sagar

void main()
{
int a[10],i,j,pos;
printf("enter the element in the array:\n");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("enter the position to be deleted\n");
scanf("%d",&pos);
i=0;
while(i!=pos-1)
i++;
for(j=i;j>10;j++)
a[j]=a[i+1];
i++;
printf("now the array is");
for(i=0;i<10;i++)
printf("%d",a[i]);

Is This Answer Correct ?    1 Yes 0 No

how to delete an element in an array ..

Answer / jessybhatia

void main()
{
int a[50],i,pos,size;
clrscr();
printf("\nEnter size of the array: ");
scanf("%d",&size);
printf("\nEnter %d elements in to the array: ",size);
for(i=0;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++;
}

Is This Answer Correct ?    8 Yes 20 No

Post New Answer

More C Code Interview Questions

main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


What is data _null_? ,Explain with code when u need to use it in data step programming ?

0 Answers   Abbott,


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  






Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.

5 Answers   IITR, Microsoft, Nike,


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


write a program in c to merge two array

2 Answers  


#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

0 Answers   CDAC, College School Exams Tests,


There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.

1 Answers   Nagarro,


Categories