Write a C program to accept n different numbers and display sum of all +ve & -ve numbers.


#include<stdio.h>
#include<conio.h>
main()
{
int arr[10];
int i,n,psum=0,nsum=0;
clrscr();
printf("\n enter how many number u want");
scanf("\n %d",&n);
printf("Enter number=");
for(i=0;i<n;i++)
 {
  scanf("\n %d",&arr[i]);
        }
 for(i=0;i<n;i++)
 {
  if(arr[i]>0)
   {
psum= psum+arr[i];
}
else
  {
  nsum= nsum+arr[i];
  }
  }
printf("\n the sum of positive number is is=%d",psum);
printf("\n the sum of negative number is is=%d",nsum);
getch();
}
/* output

 enter how many number u want5
Enter number=
12
-4
67
-3
-7
the sum of positive number is is=79
the sum of negative number is is=-14 */