There's a difficulty using the cursor method to accumulate values: nulls. If you substitute a null for one or more rows in the table, the @sum variable becomes NULL and the addition is lost, as well as the division by @i.
If you substitute zero (0) for the nulls, you're skewing the sum and therefore the average. By using the AVG(), SUM(), and COUNT() functions, they will ignore nulls properly and render correct calculations.
You can use the following to compare:
select sum(marks) sum_marks, avg(marks) avg_marks, count(marks) count_marks, count(*) count_all
, sum(case when marks is null then 1 else 0 end) count_nulls
If you replace one of the values with NULL you'll see the difference.