Showing posts with label multiply two numbers in nodejs. Show all posts
Showing posts with label multiply two numbers in nodejs. Show all posts

Sunday, July 30, 2017

Product of Two Numbers in NodeJS

Here is a simple program that I wrote using NodeJS to accept two integer value from our user and then our program will compute the product value of two number provided by our user. The code is very short and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.






Sample Program Output


Program Listing


/* Product of Two Numbers in NodeJs */
/* July 30, 2017   Sunday         */
/* Written By: Mr. Jake R. Pomperada */


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

     

console.log('\n');
console.log('Product of Two Numbers in NodeJS');
console.log('\n');
rl.question('Enter first value : ', function (x) {
   rl.question('Enter  second value : ', function (y) {
var a = parseInt(x);
var b = parseInt(y);
        var product = (a*b);
       console.log('\n');
       console.log('The product of ',a, ' and ',b, ' is ' , product,'.');
  console.log('\n');
       console.log('End of Program');
        rl.close();
    });
});