Created
August 10, 2017 17:06
-
-
Save echo-akash/38356382ca71d1c9c270331bab8e1cd8 to your computer and use it in GitHub Desktop.
Print the positive and negative numbers from given input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int a[100],p[100],ne[100],i,j,n,k,m,f1,f2; | |
k=0; | |
m=0; | |
f1=0; | |
f2=0; | |
printf("enter the number of numbers:"); | |
scanf("%d",&n); | |
printf("enter the values:"); | |
for(i=0;i<n;i++) | |
{ | |
scanf("%d",&a[i]); | |
} | |
for(i=0;i<n;i++) | |
{ | |
if(a[i]>=0) | |
{ | |
p[k]=a[i]; | |
k++; | |
f1++; | |
} | |
else | |
{ | |
ne[m]=a[i]; | |
m++; | |
f2++; | |
} | |
} | |
printf("number of positive numbers is %d",f1); | |
printf("\npositive numbers are:"); | |
for(i=0;i<k;i++) | |
{ | |
printf("%d ",p[i]); | |
} | |
printf("\nnumber of negative numbers is %d",f2); | |
printf("\nnegative numbers:"); | |
for(i=0;i<m;i++) | |
{ | |
printf("%d ",ne[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment