Skip to content

Instantly share code, notes, and snippets.

@hygull
Created April 12, 2017 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hygull/423e5e367e3a90cd2738e0965f2781d4 to your computer and use it in GitHub Desktop.
Save hygull/423e5e367e3a90cd2738e0965f2781d4 to your computer and use it in GitHub Desktop.
TypeScript - Adding 2 numbers (integers, floats)
/*
{
"created_at" : "11 April 2017 (before 02:05 am)",
"aim_of_script" : "To add 2 numbers",
"coded_by" : "Rishikesh Agrawani",
}
*/
function addition(num1:number, num2:number)
{
return (num1 + num2)
}
console.log("Sum(12, 23) = " + addition(12, 23))
console.log("Sum(23.67, 26.33) = " + addition(23.67, 26.33))
console.log("Sum(23.67, 26.3) = " + addition(23.67, 26.3))
console.log("Sum(237, 26.33) = " + addition(237, 26.33))
/*
Sum(12, 23) = 35
Sum(23.67, 26.33) = 50
Sum(23.67, 26.3) = 49.97
Sum(237, 26.33) = 263.33
*/
@engr-junaid-qazi
Copy link

how to add two numbers and print their sum on console by taking input of numbers from user ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment