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

What is a constant?

1063


What is null pointer in c?

993


How can my program discover the complete pathname to the executable from which it was invoked?

1079


What is dynamic variable in c?

1033


What is a program?

1266


What do you mean by recursion in c?

1112


How can I rethow can I return a sequence of random numbers which dont repeat at all?

1192


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1121


When is a null pointer used?

1116


Explain the Difference between the New and Malloc keyword.

1139


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

2076


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.

3153


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

1123


Is Exception handling possible in c language?

2048


writ a program to compare using strcmp VIVA and viva with its output.

2024