filmov
tv
Introduction to programming - While loop, for loop Pseudocode, flowchart, C Programing

Показать описание
Question :
Write a C program that prints a five - times multiplication table for numbers 1 through 20.
Eg of expected output
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
Using While loop:
START
number = 0 //define number as integer
counter = 1 //define counter
product = 0
While (counter //less than// or = 20) do
product = 5 * counter; //calculate the product
Print "5 X " counter "= " product
counter = counter + 1 // 2
EndWhile
STOP
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
Using for loop
START
number = 0 //define number as integer
product = 0
For counter = 1 to 20 do
product = 5 * counter; //calculate the product
Print "5 X " counter "= " product
EndFor
STOP
Write a C program that prints a five - times multiplication table for numbers 1 through 20.
Eg of expected output
5 X 1 = 5
5 X 2 = 10
5 X 3 = 15
Using While loop:
START
number = 0 //define number as integer
counter = 1 //define counter
product = 0
While (counter //less than// or = 20) do
product = 5 * counter; //calculate the product
Print "5 X " counter "= " product
counter = counter + 1 // 2
EndWhile
STOP
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
Using for loop
START
number = 0 //define number as integer
product = 0
For counter = 1 to 20 do
product = 5 * counter; //calculate the product
Print "5 X " counter "= " product
EndFor
STOP