C# Chapters

C# Program for the right most digit of a number.

Types - C# Language Fundamentals
using System;

public class Program
{
    public static void Main()
    {
        int Num, Right_Num;
        
        Console.Write("Enter Number : ");
        Num = Convert.ToInt32(Console.ReadLine());
        
        Right_Num = Num % 10;
        
        Console.Write("\n\nThe right most digit is : " + Right_Num);
    }
}

Output :
Enter Number : 123

The right most digit is : 3

Description :

Modulo (%) operator gives reminder of division of two numbers.
So Reminder of 123/10 is 3 the right most digit.


Leave a comment
Recent Comments
No Comments