array contains zeros and ones as elements.we need to bring
zeros one side and one other side in single parse.
ex:a[]={0,0,1,0,1,1,0,0}
o/p={0,0,0,0,0,1,1,1}
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
int *pointer,*pointer2,n;
printf("enter the no. of elements:");
scanf("%d",&n);
pointer=(int*)malloc(n*sizeof(n));
pointer2=(int*)malloc(n*sizeof(n));
for(int k=0,i=0,j=n-1;k<n;k++)
{
scanf("%d",(pointer+k));
if(*(pointer+k))
{
*(pointer2+(j))=*(pointer+k);
j--;
}
else
{
*(pointer2+i)=*(pointer+k);
i++;
}
}
for(i=0;i<n;i++)
printf("%d ",*(pointer2+i));
getch();
}
thaank u
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
What is the newline escape sequence?
Where static variables are stored in c?
what are the facialities provided by you after the selection of the student.
What is the use of structure padding in c?
What are the advantages of the functions?
What does main () mean in c?
How can you increase the size of a dynamically allocated array?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Explain a file operation in C with an example.
What is the heap?
difference between Low, Middle, High Level languages in c ?
What is wild pointer in c?
Explain the difference between the local variable and global variable in c?
What is difference between array and pointer in c?
How many types of arrays are there in c?