1) Given an int variable n that has already been declared and initialized to a positive value , and another int variable j that has already been declared , use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j.
2) Given int variables k and total that have already been declared , use a do...while loop to compute the sum of the squares of the first 50 positive integers and store this value in total. Thus your code should put 1*1 + 2*2 + 3*3 +... + 49*49 + 50*50 into total. Use no variables other than k and total.
for 2), second attempt is useless. If k = 0; k*k = 0 and doesn't change total.
In first attempt, the variables have already been declared, so U should not re declare them.
It is required to use do while loop, not a while, so take care, even if the result remains the same.