Expressing Imperative Programs
Functionally (1 of 4)
l
Think of the program as represented by its
flowchart.
l
int fac(int n)
{
int x, a;
x = 1; a = 1;
while( x <= n )
{
a = a*x;
x = x+1;
}
return a;
}
x = 1;
a = 1;
a = a*x;
x = x+1;
x <= n
yes
no
input n
output a