Written by @Tuncay_Pashayev.
In this problem, we have to find the number and the sum of real numbers, that are negative.
For this problem, we'll use array. After creating an array, we'll check that, if the number is negative, we'll increase the value of by and add the number to current value of . After all of these operations, we'll print the number of negative numbers and the sum of negative numbers with decimal points.
double a[n], number = 0, sum = 0;Creating array called . Setting the value of to and also setting the value of to too.
cin >> a[i];Input the element of array.
if (a[i] > 0)
{
number++;
sum += a[i];
}Checking if the number is negative, if it is then we'll increase the value of by and also add it to current value of .
cout << number << ' ';Printing the number of negative numbers..
cout.precision(2);
cout << fixed << sum;Printing the sum of negative numbers with decimal points.