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

Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

2159


regarding pointers concept

2041


How can I write a function that takes a format string and a variable number of arguments?

1058


What are the different file extensions involved when programming in C?

1284


What are different types of variables in c?

1077


Is printf a keyword?

1203


What is the function of this pointer?

1345


What is the equivalent code of the following statement in WHILE LOOP format?

1307


What is use of null pointer in c?

1017


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

1162


What's the right way to use errno?

1149


What is a nested formula?

1162


What is conio h in c?

1049


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1174


Difference between macros and inline functions? Can a function be forced as inline?

1276