Program to calculate Sum of negative and positive numbers is to add all the positive and all the negative numbers present in the array.

Positive number
A number which is greater than 0 is the positive number(integer).
Numbers 0, 1, 2,……. are positive numbers.

Negative number
A number which is less than 0 is the negative number (integer).
Numbers -1, -2, -3 …. are negative numbers.

Page Contents

Algorithm to find the Sum of negative and positive numbers

1. Declare variables. N, array[], pos, neg
2. Take a number from a user(positive and negative). array[N]
3. Traverse array from i = 1 to end
If array[i] is positive
pos =+ array[i]
If array[i] is negative
neg =+ array[i]
4. Print sum of positive and negative number. pos, neg

C program to find sum of positive and negative numbers

```#include<stdio.h>
main()
{
int i,size,pos=0,neg=0;
float avg;
printf("Enter the size of array\n");
scanf("%d",&size);
int array[size];
printf("Enter numbers to find sum of positive and negative numbers\n");
for(i=0;i<size;i++)
{
scanf("%d",&array[i]);

}
for(i=0;i<size;i++)
{
if(array[i]>0)
pos+=array[i];
if(array[i]<0)
neg+=array[i];
}
printf("The sum of positive inegers is %d\n",pos);
printf("The sum of negative integers is %d\n",neg);
}```

Output :