Skip to main content

Using the method of looping, write a program to print the table of 9 till N in the format as follows: (N is input by the user)

Using the method of looping, write a program to print the table of 9 till N in the format as follows:
(N is input by the user)

9 18 27...

Print NULL if 0 is input

Input Description:
A positive integer is provided as an input.

Output Description:
Print the table of nine with single space between the elements till the number that is input.

Sample Input :
3
Sample Output :
9 18 27

const readline = require('readline');
const inp = readline.createInterface({
input: process.stdin
});
const userInput = [];
inp.on("line", (data) => {
userInput.push(data);
});
inp.on("close", () => {
var data = userInput[0].split(" ");
var N = parseInt(data[0]);
var a=[];
for(i=1;i<=N;i++)
{a[i-1]=9*i;}
var b="";
for(i=0;i<N;i++)
{if(i==N-1)
b=b+a[i]

else
(b=b+a[i]+" ")
}

console.log(b)
});


Comments

Popular posts from this blog

Let "A" be a string. Remove all the whitespaces and find it's length.

Let " A "  be a string. Remove all the whitespaces and find it's length. Input Description: A string is provide as an input Output Description: Remove all the whitespaces and then print the length of the remaining string. Sample Input : Lorem Ipsum Sample Output : 10 const readline = require('readline'); const inp = readline.createInterface({ input: process.stdin }); const userInput = []; inp.on("line", (data) => { userInput.push(data); }); inp.on("close", () => { var data = userInput[0].split(" "); var a =''; for(i=0;i<data.length;i++) a=a+data[i]; console.log(a.length) });

You are provided with the radius of a circle "A". Find the length of its circumference.

You are provided with the radius of a circle "A". Find the length of its circumference. Note: In case the output is coming in decimal, roundoff to 2nd decimal place. In case the input is a negative number, print "Error". Input Description: The Radius of a circle is provided as the input of the program. Output Description: Calculate and print the Circumference of the circle corresponding to the input radius up to two decimal places. Sample Input : 2 Sample Output : 12.57 const readline = require('readline'); const inp = readline.createInterface({ input: process.stdin }); const userInput = []; inp.on("line", (data) => { userInput.push(data); }); inp.on("close", () => { var data = userInput[0].split(" "); var a = parseFloat(data[0]); var b = (2*3.142*a) if(a>=-1) console.log(b.toFixed(2)); else console.log("error") });

You are given with a number A i.e. the temperature in Celcius. Write a program to convert this into Fahrenheit.

You are given with a number  A  i.e. the temperature in Celcius. Write a program to convert this into Fahrenheit.  Note: In case of decimal values, round-off to two decimal places. Input Description: A number is provided in Celcius as the input of the program. Output Description: The output shall be the temperature converted into Fahrenheit corresponding to the input value print up to two decimal places and round off if required. Sample Input : 12 Sample Output : 53.60 const readline = require('readline'); const inp = readline.createInterface({ input: process.stdin }); const userInput = []; inp.on("line", (data) => { userInput.push(data); }); inp.on("close", () => { var data = userInput[0].split(" "); var a = parseInt(data[0]); var b=(a*1.8+32); console.log(b.toFixed(2)); });