Program to find the sum of positive numbers in a array
Answers
Answered by
1
Explanation:
zxs9td8rsrdihzhxhdhdnfjdgtgcjfkfgadalhpviza
Answered by
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
English,
5 months ago
Computer Science,
5 months ago
Social Sciences,
10 months ago
History,
1 year ago