What is wrong whit this code(this code is for x^j)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is wrong whit this code(this code is for x^j)?

#include <iostream> using namespace std; int main() { int x,j,i=1; cin >> x; cin>>j; if(i<=j,i++) { x*=2; } else { cout<<"power is "<<x; } return 0; }

9th Jan 2017, 12:37 PM
Mohammad Zolala
Mohammad Zolala - avatar
3 Answers
+ 6
Syntax error on if statement, there is nothing like if(i<=j, j++)
9th Jan 2017, 12:42 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 1
The if and onwards, its all wrong for(;i<=j;i++) { x*=x; } cout<<"power is"<<x;
9th Jan 2017, 12:43 PM
Samaksh Sethi
0
tnx my frinds
9th Jan 2017, 12:47 PM
Mohammad Zolala
Mohammad Zolala - avatar