I want to run an infinite loop which prints the power of the integer 2, namely 2,4,8,16. I have written this code but it is not working correctly in a loop it is giving 0 as answer. However, It works fine without loop means it gives the single answer.
#include <iostream>
using namespace std;
int main()
{
int n=2,power=1,i=1;
while(i>0)
{
power*=n;
cout<<power;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire