The result of the for loop is not outputing , i am not able to understand what is the issue with the code.

The result of the loop is not outpting, please look in the code sugest me what is the issue with the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<iostream>
using namespace std;
int main()
{
    //here int x represent the base number and y represent the power number and z is initialized
    int x,y,z;
    cout<<"Please enter the number of which power is to be cacluated"<<endl;
    cin>>x;
    cout<<endl;
    cout<<"Please enter the number up to which power is to be cacluated"<<endl;
    cin>>y;
    cout<<endl;
    for(z=1; z=y; z++)
    {
        x=x+x;
        }
    cout <<"The final output is "<<x;
    cout<<endl;
    return 0;
}
  
1
2
3
4
for(z=1; z=y; z++)
    {
        x=x+x;
        }


you probably meant == not equal,you are setting z to equal to something twice in the loop

also I think <= would make more sense

1
2
3
4
5
6

for(z=1; z<=y; z++)
    {
        x=x+x;
        }


I'm still not sure what you are trying to do though
Last edited on
thanks .
Topic archived. No new replies allowed.