
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find and Display the Multiplication Table in C#
To display multiplication table, you need to set the numbers and format the output property. Let’s say you want to find the table of 4 from 1 to 10. For that, set a while loop first till 10.
while (a <= 10) { }
Now format the output to get the result as shown below. Here, n is 4 i.e. table of 4.
Console.WriteLine(" {0} x {1} = {2}
", n, a, n * a);
The above will give a formatted output −
4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 . . .
The following is the complete example −
Example
using System; public class Demo { public static void Main() { int n = 4, a = 1; while (a <= 10) { Console.WriteLine(" {0} x {1} = {2}
", n, a, n * a); a++; } } }
Advertisements