Defining a function with For loop within For loop

h[n_] := For[i = 1, i <= n, i++,
For[j = 1, j <= n, j++,
g = g + i*j]; f = f + g;];
h[10]


I want to define a function to calculate the Sum from i to n from the Sum of j to n of i*j

Maybe you are asking for this?

h[n_] := Block[{i, j, g, f},
f = 0;
For[i = 1, i <= n, i++,
g = 0;
For[j = 1, j <= n, j++, g = g + i*j];
f = f + g;
];
f
]


However, easier and more efficient ways would be

h[n_] := Sum[i j, {i, 1, n}, {j, 1, n}]


or

h[n_] := Total[Range[1, n]]^2


or

h[n_] := (n (n + 1)/2)^2