This community-built FAQ covers the “Operator Shortcuts” exercise from the lesson “Working with Numbers”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Learn C#
FAQs on the exercise Operator Shortcuts
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (
) below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply (
) below!
Agree with a comment or answer? Like (
) to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
Why is it that the example code in the text shows “Console.Write(apple); // prints 1” in both example areas, but that particular line used for the practice gives an error in the console? Should it say "Console.WriteLine(apple); " in the examples?
If you typed Console.Write(steps)
for step 4 of the instructions, the error you get is not a compile error. It’s simply a SCT (Submitted Code Tester) error. Whoever wrote the lesson, is expecting you to use Console.WriteLine(steps)
. Either way, the value of steps
is printed to the console, but the SCT for this lesson only accepts the latter. Hope this helps!
4 Likes
Why am I getting the following, despite typing in the correct things, and getting ticks alongside the steps to say I have done the steps correctly?
Program.cs(14,17): error CS1002: ; expected [/home/ccuser/workspace/csharp-working-with-numbers-operator-shortcuts-csharp/e4-workspace.csproj]
Program.cs(14,17): error CS1525: Invalid expression term ‘+=’ [/home/ccuser/workspace/csharp-working-with-numbers-operator-shortcuts-csharp/e4-workspace.csproj]
Program.cs(18,17): error CS1002: ; expected [/home/ccuser/workspace/csharp-working-with-numbers-operator-shortcuts-csharp/e4-workspace.csproj]
Program.cs(18,17): error CS1525: Invalid expression term ‘-=’ [/home/ccuser/workspace/csharp-working-with-numbers-operator-shortcuts-csharp/e4-workspace.csproj]
The build failed. Fix the build errors and run again.
Is there a meaningful reason why Console.Write() and Console.WriteLine() don’t both work as solutions? Or is it an oversight?
So without the code itself I’m guessing, but I think your expression wants a number. Like
int step = 0; //Declare variable
step += 3; //Increase variable by three
Wanted to bring up a flaw in backend coding not allowing steps-- to function properly. WriteLine still shows 2 as the response, even though the task gets set as complete.
2 Likes
This happened to me as well.
you were meant to do Console.WriteLine(steps);
Because thats the variable putting nothing inside is wrong because the variable isn’t nothing.
Hi,
why do you have to write
"
Console.WriteLine(steps);
"
and not
"
Console.Write(steps);
"
?
Thank you.