Computer Science, asked by anaghmoghe38, 16 days ago

Write a program in Small Basicto input a number and display the product of its digits.

Answers

Answered by studyguruJi
0

Answer:

You didn't specify what programming language you want to use: for a moment I thought you meant a BASIC program. Like everything in programming, it's about the algorithm you want to use. Since you want to print a sum, and you have a starting value (2) and an ending value (the number entered), this calls for a loop of some sort. All modern programming languages have at least a WHILE loop (continue looping as long as a certain condition is true), and almost all a FOR loop (which is basically a special kind of WHILE loop). Also, you are only interested in even numbers. You could take two approaches: one is to loop over all numbers from 2 to the ending value, test whether it is even, and use it. The second approach, which I favour because it is more efficient, is to add two to the running value, as each 2nd number is an even number.

Similar questions