Problem 36. fullpyramid.js (***Revise***)

 /*Question

Full Pyramid with n= 5
*/

let fs = require("fs");
let data = fs.readFileSync(0, 'utf-8');
let idx = 0;
data = data.split('\n');

function readLine() {
idx++;
return data[idx - 1].trim();
}
//======================================================================================================

let n = 5;

for (let i = 1; i <= n; i++) // Responsible for the 5 rows
{
for (let j = 1; j <= n - i; j++) // Responsible for printing spaces
{
process.stdout.write(" ");

}

for (let k = 1; k <= 2 * i - 1; k++)// Responsible for printing stars *
{
process.stdout.write('*');


}

console.log();

}

TERMINAL:
Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$ node fullpyramid.js <input.txt * *** ***** ******* ********* Nobins-MacBook-Pro:STOC_MODULE 11SEPT 2022 nobinpunyo$












Comments

Popular posts from this blog

Problem 33. patter122333.js

Problem 38. diamond.js

Problem 16. chocolatebills.js