multiply

Multiplication of two numbers in C#

Multiplication of two numbers in C#

In this tutorial, we will discuss the concept of Multiplication of two numbers in C#

In this topic, we are going to learn how to write a program for multiplying two numbers in C# programming language

 

Multiplication of two numbers in C#

Multiplication of two numbers

Multiplication of two numbers using variable

In this program, the user declare and initialize two integer variables num1 and num2. Then two numbers are multiplied using multiplication(*) operator and assigned the result to third (mul) variable

Program 1

// Calculate multiplication of two integers in C# program 
using System; 
public class Multiplication { 
    public static void Main(string[] args) { 
        int num1=35; //declare and initialize variables
        int num2=30; 
        int mul=num1*num2; //Calculate multiplication of two numbers
        Console.WriteLine ("The multiplication of two numbers: "+mul); } }
        //display result on the screen

When the above code is executed, it produces the following result

The multiplication of two numbers: 1050

 

Program 2

In this program, the user is asked to enter two integer values. These two integers are stored in variables n1 and n2 respectively .Then these two numbers are multiplied using * operator
Then the product of n1 and n2 is evaluated and the result is stored in the mul variable. finally the result is displayed on the screen

// Calculate multiplication of two integers in C# program 
using System; public class Mul_Of_Two_Num { 
    public static void Main(string[] args) { 
        int n1, n2, mul; 
        Console.WriteLine("Find multiplication of two numbers: "); 
        Console.Write("Input number to n1: "); 
        n1=Convert.ToInt32(Console.ReadLine());
        Console.Write("Input number to n2: ");
        n2=Convert.ToInt32(Console.ReadLine());
        mul=n1*n2; 
        Console.WriteLine ("The multiplication of given two integers: "+mul); 
        Console.ReadKey(); } }

When the above code is executed, it produces the following result

Find multiplication of two numbers:
Input number to n1: 12
Input number to n2: 15
The multiplication of given two integers: 180

 

In the above program, two integer values 12,15 (get input from the user) are stored in n1 and n2. Then n1 and n2 are multiplied using the multiplication(*) operator for calculate product.

Then the result is stored in another variable mul.

Finally, the result is displayed on the screen using display statements in C#

 

Similar post

Java program to multiply two numbers

C program to multiply two numbers

C++ program to multiply two numbers

Python program to multiply two numbers

 

Java program to multiply two floating-point numbers

C program to multiply two floating-point numbers

C++ program to multiply two floating-point numbers

Python program to multiply two floating-point numbers

 

Java program to multiply two numbers using methods

C program to multiply two numbers using function

C++ program to multiply two numbers using function

Python program to multiply two numbers function

C# Subtract two floating-point  numbers using function - Example program
How to multiply two floating point numbers in C#
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 week ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

4 weeks ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

4 weeks ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

4 weeks ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

1 month ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

1 month ago