Computer Science, asked by surajekka4563, 10 months ago

Program to find the sum of positive numbers in a array

Answers

Answered by rithishvishu21
1

Explanation:

zxs9td8rsrdihzhxhdhdnfjdgtgcjfkfgadalhpviza

Answered by Rajkumarpatel89
2

Answer:

///program to find the sum of positive number in an array

#include<iostream>

using namespace std;

int main()

{

   ///variable declaration

   int sum[20];

   int sum_positive = 0;

   int number;

   ///take input from user

   cout<<"enter the size of the array:";

   cin>>number;

   cout<<"enter the element at array:";

   for(int i=0; i<=number; i++)

   {

       cin>>sum[i];

   }

   ///using for loop

   for(int i=0; i<=number; i++)

   {

       if(sum[i]>0)

       {

           sum_positive = sum_positive +sum[i];

       }

   }

   cout<<"sum of all positive numbers in an array:"<<sum_positive;

   return 0;

}

Explanation:

Similar questions