In: Computer Science
Write an application named MultiplicationTable that prompts the user for an integer value, for example 7. Then display the product of every integer from 1 through 10 when multiplied by the entered value. For example, the first three lines of the table might read 1×7=7 , 2×7=14 , and 3×7=21 using a Loop other than While if
Solution
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace MultiplicationTable
{
class Program
{
static void Main(string[] args)
{
String usrinput;
int number;
do
{
Write("Please enter an integer: ");
usrinput = ReadLine();
}while(!int.TryParse(usrinput,out number));
for(int i = 1; i <= 10; ++i)
{
WriteLine("{0} x {1} = {2}", i, number, number*i);
}
Write("Enter any key to exit...");
ReadKey();
}
}
}
Screenshot
Output