#include <iostream>
using namespace std;
class LoopEx
{
int x,y;
public:
void Ex;
{
x=3;
y=x; // y=3
while(y<=1) // 3<=1
y--; // 3, 2
x=x*y; // x= 3*3=9
cout<<x;
}
};
int main()
{
LoopEx F;
F.LoopEx();
return 0;
}
im trying to write a program for factorial of a number( 3 here), but its only calculating the last number in the loop ( 3 here) instead of calculating both 2 and 3. can some one please tell me whats wrong in the code.