i research a code, and it goes like this:

include<stdio.h>
#include<conio.h>
void main()
{
int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter  12  numbers\n");
for(i=0;i<12;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<12;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The  even numbers  are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}

~~but it is so confusing. i have edited it many times but the output is just infinity of numbers.. please help =

try using code tags on future posts heres a slightly edited version, its not much different, but cleaned i cleaned it up a little bit made it a little easier to read. i dont really know anything about conio.h, but i assume clrscr and getch are both found in it. i also doubt thats your issue, but i dont see anything wrong with the loops which is usually why a program will print endless numbers.

EDIT: not sure if this is it but after thinking it through you add to j and k one extra time. so in your print loops do as i do, j-1 and k-1

#include<stdio.h>
#include<conio.h>
void main(){

int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter 12 numbers\n");

for(i=0;i<12;i++){
scanf("%d",&a[i]);

if((a[i]%2)==0){
b[j]=a[i];
j++;
}

else{
c[k]=a[i];
k++;
}
}

printf("The even numbers are\n");

for(i=0;i<j-1;i++){
printf("%d\n",b[i]);
}

printf("The odd numbers are\n");

for(i=0;i<k-1;i++){
printf("%d\n",c[i]);
}
}

i research a code, and it goes like this:

#include<stdio.h>
#include<conio.h>
void main()
{
int a[12],b[12],c[12],i,j=0,k=0;
clrscr();
printf("Enter  12  numbers\n");
for(i=0;i<12;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<12;i++)
{
if((a[i]%2)==0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("The  even numbers  are\n");
for(i=0;i<j;i++)
{
printf("%d\n",b[i]);
}
printf("The odd numbers are\n");
for(i=0;i<k;i++)
{
printf("%d\n",c[i]);
}
getch();
}

~~but it is so confusing. i have edited it many times but the output is just infinity of numbers.. please help =

The code written by you is perfectly alright(although you have missed out "#" in first statement while putting it up) apart from the fact that you are not using a standard compiler.
The code given by you ran perfectly with the addition of the "#".No other flaws and ya try not to use conio and clrscr and all...

oh and why the hell is this a poll, the poll doesnt even make sense

~~ hehe.. i dont even know what's a poll. hehe. sorry if i posted it wrong.

This article has been dead for over six months. Start a new discussion instead.