Example Programs in C
Learn C along with me.
Monday, March 11, 2013
SORTING ARRAY OF 0 AND 1 WITH ONE LOOP example in C
source code:
#include <stdio.h>
int main(int argc, char **argv)
{
int a[]={1,1,1,1,0,0,0,0,1,1};
int j=0,i;
for(i=0;i<10;i++)
{
if(a[i]==0)
{
a[i]=1;
a[j++]=0;
}
}
for(i=0;i<10;i++)
printf("%d\n",a[i]);
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment