Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Operators | Getting Started
C# Basics

bookChallenge: 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

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); } } }

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 11

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

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

Can you explain why the subtraction needs to be performed first?

What is the original output if I don't change the brackets?

Awesome!

Completion rate improved to 1.59

bookChallenge: Operators

Sveip for å vise menyen

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); } } }

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 11
some-alt