C programming · Lesson
Observe how a condition makes part of a program optional.
if executes its block only when the condition is true; then flow continues with common statements.
INPUT n → n > 0? → TRUE: POSITIVE → END · FALSE: END
Use Start and Step: when the active block changes, ConceptStep also highlights the C lines representing that same step.
Run C executes only the example shown on the left, using stdin on the right. The coding challenge below has a separate editor and test button.
1#include <stdio.h>
2
3int main(void)
4{
5 int n;
6 scanf("%d", &n);
7
8 if (n > 0)
9 {
10 printf("POSITIVO\n");
11 }
12
13 printf("FINE\n");
14 return 0;
15}
Read an integer and print its absolute value.
This is a different program from lab 1. Complete the starter code: Check all test cases compiles this editor and tests every input, including boundary cases.
With input -3, what is printed?
Challenge 1 / 5 · Understanding
Progress: 0 / 5 · correct: 0
ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.
Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.