C Program for question given below