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 / ashok kannan
#include<stdio.h>
#include<conio.h>
void main()
{
int a[]={0,0,1,0,1,1,0,0};
int t,j=0,k=0;
while(a[j]!='\0')
{
if(a[j]==1)
j++;
if(a[k]==0)
k++;
t=i;
a[i]=a[j];
a[j]=a[t];
printf("%d",a[j]);
}
}
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
What does sizeof function do?
Explain that why C is procedural?
can we implement multi-threads in c.
What happens if a header file is included twice?
What is variable and explain rules to declare variable in c?
What are pointers really good for, anyway?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
What are different storage class specifiers in c?
How to establish connection with oracle database software from c language?
Is c pass by value or reference?
Explain data types & how many data types supported by c?
Explain how can you tell whether two strings are the same?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
Is it possible to pass an entire structure to functions?
Explain how do you determine whether to use a stream function or a low-level function?