Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Unable to understand the code
Zain Afzal
Aug 31 2017 7:17 AM
160
Reply
I am doing some basic C# exercises to learn C# which provided the solution to the problems too however, I am unable to understand the code.
Problem:
Write a C# program to check if an integer is within 20 of 100 or 200.
Sample Output:
Input an integer
25
False
Solution:
public class Exercise22
{
static void Main(string[] args)
{
Console.WriteLine("\nInput an integer:");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(result(x));
}
public static bool result(int n) {
if (Math.Abs(n - 100) <= 10 || Math.Abs(n - 200) <= 10)
return true;
return false;
}
}
Can't understand the code below:
if (Math.Abs(n - 100) <= 10 || Math.Abs(n - 200) <= 10)
return true;
return false;
I am a beginner in c# but not in overall programming
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
passing a selected comboBox string with spaces to CMD.exe
Time change format in C#