Course Content
C# Basics
C# Basics
Challenge: Operators
The program below outputs 115
. Add a pair of brackets ()
in the statement (10 + 20) * 40 / 10 - 5
changing the order of operations in such a way that it outputs 240
instead.
main
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / 10 - 5; System.Console.WriteLine(result); } } }
- Make sure the subtraction is performed in the first step.
main
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / (10 - 5); System.Console.WriteLine(result); } } }
Thanks for your feedback!