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 / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int *pointer,*pointer2,n;
printf("enter the no. of elements:");
scanf("%d",&n);
pointer=(int*)malloc(n*sizeof(n));
pointer2=(int*)malloc(n*sizeof(n));
for(int k=0,i=0,j=n-1;k<n;k++)
{
scanf("%d",(pointer+k));
if(*(pointer+k))
{
*(pointer2+(j))=*(pointer+k);
j--;
}
else
{
*(pointer2+i)=*(pointer+k);
i++;
}
}
for(i=0;i<n;i++)
printf("%d ",*(pointer2+i));
getch();
}


thaank u

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does sprintf put null character?

987


How can I run c program?

1126


How do we make a global variable accessible across files? Explain the extern keyword?

1827


What is the difference between text files and binary files?

1283


Why c is called object oriented language?

1007


What is the use of parallelize in spark?

976


What is strcmp in c?

1018


What is context in c?

884


How can I manipulate strings of multibyte characters?

1077


Why we use void main in c?

1099


How can you find the exact size of a data type in c?

952


Why is c fast?

1009


What is dynamic memory allocation?

1283


Differentiate fundamental data types and derived data types in C.

984


Why does everyone say not to use gets?

1027