Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Desafio: Operadores | Introdução
Fundamentos de C#

bookDesafio: Operadores

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

main.cs

copy
1234567891011
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / 10 - 5; System.Console.WriteLine(result); } } }
  1. Make sure the subtraction is performed in the first step.
main.cs

main.cs

copy
1234567891011
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / (10 - 5); System.Console.WriteLine(result); } } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 11

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Where should I place the brackets to get the result 240?

Can you explain why subtracting first changes the result?

Can you show the calculation steps for both 115 and 240?

bookDesafio: Operadores

Deslize para mostrar o 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

main.cs

copy
1234567891011
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / 10 - 5; System.Console.WriteLine(result); } } }
  1. Make sure the subtraction is performed in the first step.
main.cs

main.cs

copy
1234567891011
namespace TestConsoleApp { internal class Program { static void Main(string[] args) { int result = (10 + 20) * 40 / (10 - 5); System.Console.WriteLine(result); } } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 11
some-alt