program help: array sort odd & even numbers - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

program help: array sort odd & even numbers

shaieenshaieen Posts: 20Member
i ran the program but it have errors. kindly check them huh? thanks!!
and..

please add codes for this to the program:

[b]if a negative number is encountered, the program prompts the user" Negative number encountered" and ask for another input.

[/b]


#include
#include
void main(){

int a[10],b[10],c[10],i,j=0,k=0;
clrscr();

printf("Enter 10 positive numbers:
");
for(i=0;i<10;i++){
scanf("%d",&a[i]);}
for(i=0;i<10;i++){
if((a[i]%2)==0){
b[j]=a[i];j++;}
else{
c[k]=a[i];
k++;
}
}

printf("The even numbers are:
");
for (i=0;[color=Red]i<j-1[/color];j++)}
printf("%d
",b[i]);
}
printf("The odd numbers are:
");
for(i=0;[color=Red]i<k-1[/color];i++){
printf("%d
",c[i]);}
getch();


}

Comments

Sign In or Register to comment.