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 / manoj
#include<stdio.h>
#include<conio.h>
void main()
{
int a[]={0,0,1,0,1,1,0,0};
int *arrayTemp = a;
int i, j_0 = 0, j_8 = 8;
for(int data = 0; *a != '\0'; *a++)
{
data = *a;
if(data == 1 )
{
a[j_0++] = data;
}
else
{
a[j_8--] = data;
} // if-else block
}//for loop
}//main function
for(i=0; i< 8; i ++)
{
printf("array value is %d", a[i]);
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What is a constant?
What is null pointer in c?
How can my program discover the complete pathname to the executable from which it was invoked?
What is dynamic variable in c?
What is a program?
What do you mean by recursion in c?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
When is a null pointer used?
Explain the Difference between the New and Malloc keyword.
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
Is Exception handling possible in c language?
writ a program to compare using strcmp VIVA and viva with its output.