Understand usage of while loop. You can refer this tutorial for that.All you have to do is take input from user in while loop, Keep sum of numbers read in one variable. And at the end out of loop, divide sum by 6. That would be your average.