TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zain Afzal
NA
2
1.5k
Unable to understand the code
Aug 31 2017 7:17 AM
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
Reply
Answers (
1
)
passing a selected comboBox string with spaces to CMD.exe
Time change format in C#