A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# program to check if an given integer is within 20 of 100 or 200
Q:

Write a C# program to check if an given integer is within 20 of 100 or 200

0

Write a C# program to check if an given integer is within 20 of 100 or 200

Sample Output:

Input an integer: 25                                                                     
False 

Sample Output:

Input an integer: 50
False

Sample Output:

Input an integer: 70
False

Sample Output:

Input an integer: 80
True

Sample Output:

Input an integer: 90
True 

Sample Output:

Input an integer: 110
True
 

Sample Output:

Input an integer: 120
True 

Sample Output:

Input an integer: 125
False 

Sample Output:

Input an integer: 130
False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;

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) <= 20 || Math.Abs(n - 200) <= 20)
   return true;
  return false;
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now