Solved problem in C