Ex.2: Sum of the first n naturals
unsigned int sum(unsigned int n)
{
unsigned int s= 0;
int i;
for(i=0; i<=n; i++)
return s;
}
void main()
{
unsigned int n=20;
printf("The sum of the first ", n, " naturals is ", sum(n), " !");
}
- - - - - - - - - - - < Output > - - - - - - - - - - -
The sum of the first 20 naturals is 210 !
Last update : October 20, 2003
If interested in this project, please fell free to contact the personnel of
our group. The project leader is dr.drs. L.J.M. Rothkrantz