You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
607 B
C#

/*
* C# Program to Display Absolute value of a Number
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace example
{
internal class Program
{
private static void Main(string[] args)
{
int num;
Console.Write("Enter a number:");
num = Convert.ToInt32(Console.ReadLine());
if (num < 0)
{
num = num * -1;
}
Console.WriteLine("Absolute value : " + num);
Console.ReadLine();
}
}
}
/*
Output:
Enter a number:-50
Absolute value : 50