ConceptStep · learning platform for computer science

Compound conditions: &&, || and !

C programming · Lesson

C · lesson 10 / 27

Compound conditions: &&, || and !

Combine multiple conditions and observe how one decision is built from several subconditions.

1 · Observe and predict

The concept

&& requires both conditions, || requires at least one, and ! negates a result. The flowchart uses equivalent AND/OR/NOT operators.

Mental model:

(adult OR accompanied) AND NOT blocked → ALLOWED/DENIED

2 · Flowchart First

Follow the same algorithm as a flowchart

Use Start and Step: when the active block changes, ConceptStep also highlights the C lines representing that same step.

Loading flowchart…
3 · Flowchart ↔ C · Run in Page

Lab 1 — Run the example program

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.

Compound conditions Start the flowchart to synchronize the code
                        1#include <stdio.h>
                        2 
                        3int main(void)
                        4{
                        5    int eta;
                        6    int accompagnato;
                        7    int bloccato;
                        8 
                        9    scanf("%d", &eta);
                        10    scanf("%d", &accompagnato);
                        11    scanf("%d", &bloccato);
                        12 
                        13    if ((eta >= 18 || accompagnato == 1) && !(bloccato == 1))
                        14    {
                        15        printf("AMMESSO\n");
                        16    }
                        17    else
                        18    {
                        19        printf("BLOCCATO\n");
                        20    }
                        21 
                        22    return 0;
                        23}
Ready. Make a prediction before running.

                    
                

Lab 2 — Coding challenge: write your code — Inclusive interval

Read an integer; print SI only if it is between 10 and 20 inclusive, otherwise NO.

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.

4 · Guided practice

Check your prediction

With age 16, accompanied = 1 and blocked = 0, what is the result?

Challenge 1 / 5 · Understanding

Progress: 0 / 5 · correct: 0

Your competency map

What you need to know for Compound conditions: &&, || and !

ConceptStep separates what is required from what is recommended or useful as reinforcement. Only required prerequisites block your progress.

Current topic Strong skill Review due Needs reinforcement To be mastered Optional support

Relationships: solid line = required · dashed line = recommended · dotted line = reinforcement.

GUIDED LEARNING PATHS

Want to choose the next skill to develop?