Maha

Maha

  • NA
  • 0
  • 326k

Multiplication table of any number

Apr 30 2014 8:48 AM
Following program is from a website. If + sign is removed the o/p is 10 * 10 = 100 only, please explain the reason. Problem is highlighted.

//If we know the range we will go for "for" loop.

using System;
class Program
{
static void Main(string[] args)
{
Console.Write("Table of: ");

int n = int.Parse(Console.ReadLine());

string s = "";

Console.WriteLine();

for (int i = 1; i <= 10; i++)
s += n + " * " + i + " = " + n * i + "\n";

Console.WriteLine(s);

Console.ReadKey();
}
}
/*
Table of: 10

10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100
*/


Answers (2)