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
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Explain how can you determine the size of an allocated portion of memory?
Who developed c language and when?
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
What is the explanation for the dangling pointer in c?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
What is the method to save data in stack data structure type?
Why c is called free form language?
Is null equal to 0 in sql?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
How do you define CONSTANT in C?
How to declare pointer variables?
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is the size of enum in c?
What are the advantages of union?