Input ten numbers in an array and if these are positive numbers then store it in first array or if these are negative numbers then store it in second array.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int i, j = 0, k = 0, num[10], ne[10], po[10];
clrscr ( );
printf ("\n\t\t Sorting of positive and negative numbers\n\n");
for ( i = 0; i < 10; i++ )
{
printf ("\n\t\t\t Enter a number......:"); scanf ("%d", & num[i]);
if ( num[i] > 0 )
po[ j++] = num[i];
else
ne[ k++] = num[i];
}
printf ("\n\n\t Positive numbers =");
for ( i = 0; i < j; i++ )
{
printf (" %d", po[i]);
}
printf ("\n\n\t Negative numbers = ");
for ( i = 0; i < k; i++ )
{
printf (" %d", ne[i]);
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment