1. ## pseudocode

i have to write a program after the pseudocode that i already have :
Code:
```READ X
Y <-- 1
Counter <-- N
WHILE Counter > 0
Y <-- Y*X
Counter <-- Counter-1
EndWHILE
WRITE Y```
That is the algorithm of the program. You must enter a number X that is a float and a N that is int .

my code looks like this but it's not correct when i entered the values it doesn't calculate it right.

Code:
```#include <stdio.h>
#include <conio.h>
int main()
{
int Y,N,Counter;
float X;
printf("Enter the real number:\n");
scanf("&#37;f",&X);
printf("Enter natural number:\n");
scanf("%d",&N);
Y = 1;
Counter = N;
while(Counter > 0)
{
Y = Y * X;
Counter = Counter-1;
}
printf("The final result is:\n%d",Y);
getch();

}```
Do i have to convert Y to float also to work?
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.
Thank You

2. my code looks like this but it's not correct when i entered the values it doesn't calculate it right.
What values did you enter? Perhaps it is your expectation of the result that is incorrect.

3. Let's say you enter tge real number X=3 and the natural nr N=10.
59049 is the result does it look ok ?
i don't think so

4. Let's say you enter tge real number X=3 and the natural nr N=10.
59049 is the result does it look ok ?
Yes, it looks perfectly fine to me.

Do you understand what your algorithm does?

5. actually don't .
i enter a real number .
i enter a natural number.
it does a loop . the N number specify the number of times the loop is run?
if N <0 it doesn't execute the while sequence .
What i don't understand is what Counter = Counter - 1 ?

6. Here's a hint:
Try with X=2 and N=1. Then try again with N=2. Then N=3, 4, 5...

Of course, this would just be "engineer's intuition", since you are figuring out what the algorithm does based on a limited pattern. However, once you have your guess, go through your X=3 and N=10 case again, step by step, looking at how Y and Counter change on each iteration of the loop.

7. 1 more thing Y is integer and X is float
Y = Y*X is this allowed?
i mean does it convert X to integer
lets say if i enter the X 3,14 ?
what happends then with it?

8. Y = Y*X is this allowed?
Yes, but it means that your floating point values get truncated, so your calculations are more inaccurate,

i mean does it convert X to integer
More like the result of Y*X is truncated to an int.

9. thanks for all your help .
how you think the accurate program should look ?