in C++ i am getting two errors regarding illegal else without matching if , and i have dont i myself the last step of my project is to obtain the average of all non positive numbers and average of all negative numbers as well as the sum of just the negatives
1- am i doing this write in theory if i create 2 if statements that if the numbers are less then 0 just take the average of those thus the reason for declaring answer3 /4
even though i am having errors is my algorithm right?
#include <iostream>
using namespace std;
int main ()
{
int num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,answer,answer1,answer3,answer4;//declaring the numbers as intigers
cout<<"this program will have you input in 10 whole numbers.\n";
cout<<"please enter in ten whole numbers followed by a comma";//asking you to input the numbers
cout<<"enter in num1.\n";//enter in the numbers
cin >> num1;
cout<<"enter in num2.\n";
cin >> num2;
cout<<"enter in num3.\n";
cin >> num3;
cout<<"enter in num4.\n";
cin >> num4;
cout<<"enter in num5.\n";
cin >> num5;
cout<<"enter in num6.\n";
cin >> num6;
cout<<"enter in num7.\n";
cin >> num7;
cout<<"enter in num8.\n";
cin >> num8;
cout<<"enter in num9.\n";
cin >> num9;
cout<<"enter in num10.\n";
cin >> num10;
answer=num1+num2+num3+num4+num5+num6+num7+num8+num9+num10;//formula to get the sum of the number
cout<<"the sum of the ten numbers are"<<answer<<endl;
answer1=(num1+num2+num3+num4+num5+num6+num7+num8+num9+num10)/10;
cout<<"the average is"<<answer1<<endl;
if (num1,num2,num3,num4,num5,num6,num7,num8,num9,num10 < 0);//an if statement stating that if the number is greater then 0 or less then zero to show how much greater or less than it is
{
answer3=num1+ num2+num3+num4+num5+num6+num7+num8+num9+num10;
cout<<"the sum of all positives" <<answer3<<endl;
}
else
(num1,num2,num3,num4,num5,num6,num7,num8,num9,num10 > 0);
{
answer4=num1+ num2+num3+num4+num5+num6+num7+num8+num9+num10;
cout<<"the sum of the negatives greater than 0 is"<<answer4<<endl;
}
return 0;
}