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?
1
Expert's answer
2014-03-24T11:35:03-0400
/*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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal