60 369
Assignments Done
98,1%
Successfully Done
In April 2018

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?
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions