programming question tried for practice