Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why can arithmetic operations not be performed on void pointers?

981


write a program to print data of 5 five students with structures?

2004


Are pointers integer?

958


why we wont use '&' sing in aceesing the string using scanf

2308


Can a file other than a .h file be included with #include?

1098


How are 16- and 32-bit numbers stored?

1237


what is the significance of static storage class specifier?

2184


What is queue in c?

1031


Explain what does the function toupper() do?

1005


please send me the code for multiplying sparse matrix using c

2119


What is the advantage of a random access file?

1128


What is difference between static and global variable in c?

979


Write a C program in Fibonacci series.

1045


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

1047


how to write optimum code to divide a 50 digit number with a 25 digit number??

3203