taks kamps

taks kamps

  • NA
  • 39
  • 6.1k

if -else inclusive

Dec 1 2018 3:46 PM
Should output success if I is within 5 units of j… im getting failure with this code
 
  1. using System;  
  2. namespace HelloWorld  
  3.   
  4. {  
  5.   
  6. class Program  
  7.   
  8. {  
  9.   
  10. static void Main(string[] args)  
  11.   
  12. {  
  13.   
  14. string output;  
  15.   
  16. int i = 10;  
  17.   
  18. int j = 10;  
  19.   
  20. if(i == j + 5|| (i == j - 5))  
  21. {  
  22. output = "Success";  
  23. }  
  24. else  
  25. {  
  26. output = "Failure";  
  27. }  
  28. Console.WriteLine(output);  
  29. }  
  30. }  

Answers (1)