.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

to find modulas

Posted By: Chandranshu Awasthi     Posted Date: February 13, 2011    Points:2   Category :C#
Can Anyone plz help me to slove the prblm

|5-6| i have to calculate dis in C# which function i should use

Responses
Author: Creative13             
Posted Date: September 07, 2011     Points: 20   

Hey Chandranshu,

You can do it by using Math.Abs() Method.

e.g.
   
using System;

class Program
{
static void Main()
{
//
// Compute two absolute values.
//
int value1 = -1000;
int value2 = 20;
int abs1 = Math.Abs(value1);
int abs2 = Math.Abs(value2);
//
// Write integral results.
//
Console.WriteLine(value1);
Console.WriteLine(abs1);
Console.WriteLine(value2);
Console.WriteLine(abs2);
//
// Compute two double absolute values.
//
double value3 = -100.123;
double value4 = 20.20;
double abs3 = Math.Abs(value3);
double abs4 = Math.Abs(value4);
//
// Write double results.
//
Console.WriteLine(value3);
Console.WriteLine(abs3);
Console.WriteLine(value4);
Console.WriteLine(abs4);
}
}

Output
-1000
1000 (Absolute value)
20
20 (Absolute value)
-100.123
100.123 (Absolute value)
20.2
20.2 (Absolute value)






Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend