solved problem 1 in c