40182: Given an Integer variable k that has already been declared, use a Do...Loop While loop to print a single line consisting of 53 asterisks. Use no variables other than k.
k = 0
Do
Console.Write("*")
k += 1
Loop Until (k = 53)
40183: Given an int variable n that has already been declared and initialized to a positive value, use a Do...Loop While loop to print a single line consisting of n asterisks. Use no variables other than n.
Do
Console.Write("*")
n -= 1
Loop Until (n = 0)
40387: Write a statement that increments the value of the int variable total by the value of the int variable amount. That is, add the value of amount to total and assign the result to total.
total += amount
40184: Given int variables k and total that have already been declared, use a Do...Loop While loop to compute the sum of the squares of the first 50 whole numbers, 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.
k = 1
total = 0
Do While (k <= 50)
total = (total + (k*k))
k += 1
Loop
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 for 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.
ReplyDelete