Zero Check in C

Level 257 keystrokes

Checks with an if statement whether val equals zero using ==; val is 0, so it prints "Value is zero".

C code

// The value to test is 0
1int val = 0;
// == compares for equality; a single = would assign 0 instead and make the test false
2if (val == 0) {
// val == 0 is true, so "Value is zero" is printed
3 printf("Value is zero\n");
4}

Output

Value is zero
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this C code and how often they appear.

  • =× 3
  • ;× 2
  • "× 2
  • (× 2
  • )× 2
  • {× 1
  • }× 1
  • \× 1

More C examples at level 2

← C typing practice