# Answer to Question #40413 in C++ for Bella

Question #40413

#include <iostream>

using namespace std;

void main()

{

const int n=100000;

int x[n],i;

for (int i=0; i<=n-2; i++)

{

if x[i]<= x[i+1];

cout<< "1";

}

else

cout<<"0";

system ("pause");

}

The code doesn't seem to work. It says illegal else without if !!! As well as the syntax error for the identifier 'x'. Can anyone plz tell me where are the mistakes?

using namespace std;

void main()

{

const int n=100000;

int x[n],i;

for (int i=0; i<=n-2; i++)

{

if x[i]<= x[i+1];

cout<< "1";

}

else

cout<<"0";

system ("pause");

}

The code doesn't seem to work. It says illegal else without if !!! As well as the syntax error for the identifier 'x'. Can anyone plz tell me where are the mistakes?

Expert's answer

/*Dear visitor,

please try this code

*/

#include <iostream>

#include <stdlib.h>

using namespace std;

int main() {

const int n=100000;

int x[n];

int i;

for ( i=0; i<=n-2; i++) {

if (x[i] <= x[i+1]) {

cout<< "1";

}

else {

cout<<"0\n";

break;

}

}

system ("pause");

return 0;

}

please try this code

*/

#include <iostream>

#include <stdlib.h>

using namespace std;

int main() {

const int n=100000;

int x[n];

int i;

for ( i=0; i<=n-2; i++) {

if (x[i] <= x[i+1]) {

cout<< "1";

}

else {

cout<<"0\n";

break;

}

}

system ("pause");

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment