how to delete an element in an array
Answers were Sorted based on User's Feedback
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 |
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 |
Find your day from your DOB?
15 Answers Accenture, Microsoft,
Write a C function to search a number in the given list of numbers. donot use printf and scanf
char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }
int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p
main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }
main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O
given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit
main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }
main() { clrscr(); } clrscr();
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }