Using for loop would be easier for you. You can do it with while or do_while also:) all the loops will take same time. Or you can use recursion also.
You can write foor loop as :-


int i;...