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.cs
1234567891011namespace 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.cs
1234567891011namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / (10 - 5); System.Console.WriteLine(result); } } }
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 11
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.59
Challenge: Operators
Swipe to show menu
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.cs
1234567891011namespace 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.cs
1234567891011namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / (10 - 5); System.Console.WriteLine(result); } } }
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 11