mardi 21 avril 2020

Expected a statement error while using else if (C++)

I'm trying to see the output but it always returns the "expected a statement" error message. I would appreciate any help, thanks.

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{

        int const n = 6;

        int A[n] = {1,-2,3,-4,5,-6}, i, p,x;
        int T[n] = {1,3,5};
        int U[n] = {-2,-4,-6};

        p = 1;
        x = 1;

        for (i = 0; i < n; i++)
        {
            if (A[i] < 0)
            p = p * U[i] * U[i];
            cout << "Test" << p << "\n";


            else if (A[i] > 0)
            { 

            x = x * T[i] * T[i] * T[i];

            cout << "Test2" << X << "\n";

            }

        }
return 0
}

Aucun commentaire:

Enregistrer un commentaire