i have to write a program after the pseudocode that i already have :
That is the algorithm of the program. You must enter a number X that is a float and a N that is int .
Y <-- 1
Counter <-- N
WHILE Counter > 0
Y <-- Y*X
Counter <-- Counter-1
my code looks like this but it's not correct when i entered the values it doesn't calculate it right.
Do i have to convert Y to float also to work?
printf("Enter the real number:\n");
printf("Enter natural number:\n");
Y = 1;
Counter = N;
while(Counter > 0)
Y = Y * X;
Counter = Counter-1;
printf("The final result is:\n%d",Y);
when i compile it and test it gives some numbers but not the ones it supose to .
i also must specify this is not portable code its Borland C++ 3.1 DOS version.
Please help me out or tell me where to study more.