Programming basics - If statement

3 important questions on Programming basics - If statement

Within which context is a variable valid?

A VARIABLE IS ONLY VALID WITHIN IT S OWN CODE BLOCK! Goes down, but not up!

What can you do if you have only 1 line of code and an if/else or if else statement?

You can drop the curly braces.

How can you shorten blocks of code with different else and if else statements? What is the limitation here?

string message = (userValue == "1") ? "boar" : "strand of just";

If the uservalue is true for 1, then (questionmark) do boar. If false, then take everything after the column. Only valuable when only 2 values111

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo