Contact Learn C
Copy Program Share Program

Program 103:To find Sum of Negative and Positive integers

Program 103:
#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);
   
    
}

Explanation:



Output:

To find Sum of Negative and Positive integers

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide