/*
prints positive and negative numbers separately from a series of numbers.
eg. 1 8 -5 -9 3 -4
will print 1 8 3 -5 -9 -4
*/
#include< stdio.h>
#include< conio.h>
void main()
{
int n,a[20],b[20],c[20],i,j,k;
char ch;
do
{
clrscr();
a[0]=0;
j=k=0;
printf("Enter a decimal no (1-10) : ");
scanf("%d",&n);
printf("\nEnter numbers -->\n\n");
for(i=0;i {
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}
for(i=0;i {
if(a[i]>=0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("\n\n:: RESULT ::\n\n");
for(i=0;i printf("%d ",b[i]);
for(i=0;i printf("%d ",c[i]);
printf("\n\n\nContinue with another no : (y/n) ? : ");
ch=getch();
}while(ch=='y'||ch=='Y');
}
prints positive and negative numbers separately from a series of numbers.
eg. 1 8 -5 -9 3 -4
will print 1 8 3 -5 -9 -4
*/
#include< stdio.h>
#include< conio.h>
void main()
{
int n,a[20],b[20],c[20],i,j,k;
char ch;
do
{
clrscr();
a[0]=0;
j=k=0;
printf("Enter a decimal no (1-10) : ");
scanf("%d",&n);
printf("\nEnter numbers -->\n\n");
for(i=0;i
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}
for(i=0;i
if(a[i]>=0)
{
b[j]=a[i];
j++;
}
else
{
c[k]=a[i];
k++;
}
}
printf("\n\n:: RESULT ::\n\n");
for(i=0;i
for(i=0;i
printf("\n\n\nContinue with another no : (y/n) ? : ");
ch=getch();
}while(ch=='y'||ch=='Y');
}
No comments:
Post a Comment