#include <stdio.h>

int foo( int n, void (*notify)(int) )
{
    int sum = 0 ;
	for( int i = 1 ; i < n ; ++i )
	{
		sum += i*i ;
		notify(sum) ;
	}
	return sum ;
}

void report_progress( int s )
{ printf( "intermediate value returned: %d\n", s ) ; }

int main()
{
    foo( 10, report_progress ) ;
}
