Produce an equivalent code segment using for loop for the following code segment :

SUM =0:

n = 1;

While (n < = I 0)

{

SUM = SUM + n * n ;

n = n+ 1 ;

}

print f ( "SUM = % d\n", SUM );

Subject Programming Language
NU Year Set: 4.(b) Marks: 4 Year: 2012
Login to post your comment.