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 / nitin garg

#include <stdio.h>
#include <conio.h>
#include <string.h>

int main()
{

int num[100],num1[100],n,n1,i,i1=1;
printf("how many elements you enter
");
scanf("%d",&n);
n1=n;
printf("Enter %d elements
",n);
for(i=1;i<=n;i++)
{
scanf("%d",&num[i]);
}

for(i=1;i<=n;i++)
{
if(num[i]==0)
{
num1[i1]=num[i];
i1++;
}
else
{
num1[n1]=num[i];
n1--;

}
}

printf("
Seprate zeor one
");
for(i=1;i<=n;i++)
{
printf("%d ",num1[i]);
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the size of enum in bytes?

1091


What is function what are the types of function?

1007


How do you define structure?

1051


What are file streams?

1022


What is the stack in c?

1164


What are the types of macro formats?

1128


What is the difference between printf and scanf in c?

1366


How many types of functions are there in c?

1152


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3527


Explain how do you generate random numbers in c?

1093


Explain what are the standard predefined macros?

1125


How can I manipulate strings of multibyte characters?

1115


What are the advantages of using linked list for tree construction?

1104


what are non standard function in c

1918


How can I prevent another program from modifying part of a file that I am modifying?

1065