Basic Programming C# Examples

C# Program to print the result of Dividing two number

The Program in C# Program to print the result of Dividing two numbers is given below:

using System;

namespace DivisionOfTwoNumbers
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Codeauri Famuly, Enter the first number and Second number here to find their division: ");
            Console.WriteLine("Well,Enter the first number: ");
            int num1 = Convert.ToInt32(Console.ReadLine());
            
            Console.WriteLine("Well,Enter the second number: ");
            int num2 = Convert.ToInt32(Console.ReadLine());
            
            int division = num1 / num2;
            Console.WriteLine("Okay, the division of " + num1 + " by " + num2 + " is: " + division);
        }
    }
}

Output:

Hello Codeauri Famuly, Enter the first number and Second number here to find their division: Well,Enter the first number: 90
Well,Enter the second number:
10
Okay, the division of 90 by 10 is: 9

Pro-Tips💡

Here are the steps by steps execution of above code:

  • Start by using the System namespace to access the Console class, which is used to read from and write to the console.
  • Create a new namespace called DivisionOfTwoNumbers and define a Program class within it.
  • Define a Main method within the Program class, which will be the starting point of the program.
  • Within the Main method, use the WriteLine method of the Console class to prompt the user to enter the first number.
  • Read the user’s input using the ReadLine method and convert it to an integer using the Convert.ToInt32 method, storing the result in a variable named num1.
  • Use the WriteLine method to prompt the user to enter the second number and read the input in a similar manner, storing the result in a variable named num2.
  • Perform the division of num1 by num2 and store the result in a variable named division.
  • Use the WriteLine method to print the result of the division, using string concatenation to display both numbers and the result.

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

Programming Languages( Types, Pros and Cons)-Codeauri

What are the types or levels of Programming Languages? The types or levels of programming languages are divided into two types: Types Of Programming Languages: 1.Machine-level Language :1st…

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X