40178: Given an integer variable k that has already been declared, use a While loop to print a single line consisting of 88 asterisks. Use no variables other than k.
k = 0
Do While (k < 88)
Console.Write("*")
k += 1
Loop
40179: Given an Integer variable n that has already been declared and initialized to a positive value, use a While loop to print a single line consisting of n asterisks. Use no variables other than n.
Do While (n > 0)
Console.Write("*")
n -= 1
Loop
40180: Given Integer variables k and total that have already been declared, use a 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
40181: Given an Integer variable n that has been initialized to a positive value and, in addition, Integer variables k and total that have already been declared, use a While loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables other than n,k, and total.
k = 0
total = 0
Do While (k <= n)
total = (total + (k*k*k))
k += 1
Loop
40379: Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a while loop to compute the sum of the cubes of the first n counting numbers, and store this value in total. Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total. Use no variables other than n, k , and total. Do NOT modify n.
k = 0
total = 0
Do While (k <= n)
total = (total + (k*k*k))
k += 1
Loop
40378: Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting 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
No comments:
Post a Comment