Chep June Chep June - 10 days ago 10
C++ Question

error expected primary-expression before ';'token c++

am new in coding and am using c++ to create a program to find sum median maximum and minimum but i get the error expected primary-expression before ';' token in every place that has cout

#include <iostream>
using namespace std;

int main()
{
int array[10],maximum,minimum,sum=0,median;
cout<<"input ten integers,"<<;
for(int i=0; i<10; i++){
cin>> array[i];
sum=sum+array[i];
}
for(int i=0; i<10; i++){
if(maximum>array[i])
{
maximum=array[i];
}
else if( minimum<array[i])
{
maximum= array[i];
}
}
median=(array[4]+array[5])/2;

cout<<"maximum value is"<<maximum<<;
cout<<"minimum value is"<<minimum<<;
cout<<"sum is"<<sum<<;
cout<<"median is"<median<<;

Answer

Remove the << before the ; on every line that has it or replace <<; with <<'\n'; for a new line.

#include <iostream>
using namespace std;

int main()
{
    int array[10], maximum = 0, minimum = 0, sum = 0, median = 0;

    cout << "input ten integers: ";

    for (int i = 0; i < 10; i++) {
        cin >> array[i];
        sum = sum + array[i];
    }
    for (int i = 0; i < 10; i++) {
        if (maximum > array[i])
        {
            maximum = array[i];
        }
        else if (minimum < array[i])
        {
            maximum = array[i];
        }
    }
    median = (array[4] + array[5]) / 2;

    cout << "maximum value is " << maximum << '\n';
    cout << "minimum value is " << minimum << '\n';
    cout << "sum is " << sum << '\n';
    cout << "median is " << median << '\n';

    return 0;
}