


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Write a program that prints the next n odd numbers (starting from 1) and on the last row prints the sum of them.
On the first line, you will receive a number – n. This number shows how many odd numbers you should print.
Print the next n odd numbers, starting from 1 , separated by new lines. On the last line, print the sum of these numbers.
n will be in the interval [1…100]
Input Output Input Output 5 1 3 5 7 9 Sum: 25
Sum: 9
You will receive an integer as an input from the console. Print the 10 times table for this integer. See the examples below for more information.
Print every row of the table in the following format: {theInteger} X {times} = {product}
The integer will be in the interval [1…100]
Input Output Input Output 5 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 5 X 6 = 30 5 X 7 = 35 5 X 8 = 40 5 X 9 = 45 5 X 10 = 50
Hints
3. Multiplication Table 2. Rewrite you program so it can receive the multiplier from the console. Print the table from the given multiplier to 10. If the given multiplier is more than 10 - print only one row with the integer , the given multiplier and the product. See the examples below for more information.
Print every row of the table in the following format: {theInteger} X {times} = {product}
The integer will be in the interval [1…100]
Input Output Input Output Input Output 5 1
This code uses two nested for loops to print the desired pattern. The outer loop iterates through each row of the triangle, while the inner loop prints the appropriate number for that row. Since we want to print the same number for each row, we simply use the outer loop index variable i for the number. The Console.Write(i) statement prints the current number without moving to a new line, while Console.WriteLine() moves to a new line after all numbers have been printed for that row.