while (num1[a] == 0 && a < b) a++;
while (num1[b] == 1 && a < b)
b––;
if (a < b)
{
num1[a] = 0;
num1[b] = 1;
a++;
b––;
}
}
}
int main()
{
int num[] = {1, 0, 1, 0, 1, 0, 1, 1, 0};
int z = 9, x = 0;
abc(num, z);
for (x = 0; x < 9; x++)
printf("%d ", num[x]);
getchar();
return 0;
}
" class="related-a">
What will be the output of the following program?
#include <stdio.h>
void abc(int num1[], int size)
{
int a = 0, b = size–1;
while (a < b)
{
while (num1[a] == 0 && a < b)
a++;
while (num1[b] == 1 && a < b)
b––;
if (a < b)
{
num1[a] = 0;
num1[b] = 1;
a++;
b––;
}
}
}
int main()
{
int num[] = {1, 0, 1, 0, 1, 0, 1, 1, 0};
int z = 9, x = 0;
abc(num, z);
for (x = 0; x < 9; x++)
printf("%d ", num[x]);
getchar();
return 0;
}