By integrating potential energy expression over one complete period and then divide by the time for one period. you can read more here.
Link: https://www.askiitians.com/forums/Wave-Motion/a-prove-that-in-simple-harmonic-motion-the-average_123804.htm
Study 40% syllabus and score up to 100% marks in JEE