💩

programierds

Tests
C Beginner 5 min

Ordering: variables and constants in C

Drag the lines until you reconstruct a C program that declares variables, uses them and defines a constant.

lines

9

This test asks you to reconstruct, line by line, a C program that reviews what you saw in the lesson on variables and constants.

The idea:

  1. Include the header needed for printf.
  2. Open main.
  3. Declare and initialize the age variable.
  4. Declare the monthsPerYear constant.
  5. Reassign age.
  6. Print age first and then monthsPerYear.
  7. Return 0.

Drag the lines or use the arrows until they are in the correct order. You have a time limit.

Tiempo estimado

05:00:00

Lineas: 9

C Ordenar codigo Beginner 5 min 9 lineas

Ordering: variables and constants in C

Drag the lines until you reconstruct a C program that declares variables, uses them and defines a constant.

Algoritmo a ordenar

Order the lines to build a C program that declares a variable, modifies it, declares a constant and prints both values.

Arrastra las lineas o usa los botones de flecha para reordenarlas. Cuando creas que estan en el orden correcto, tocas Verificar ordenamiento.

Lineas mezcladas c
  1. 1
    #include <stdio.h>
  2. 2
    int main() {
  3. 3
        int age = 18;
  4. 4
        const int monthsPerYear = 12;
  5. 5
        age = 19;
  6. 6
        printf("Age: %d\n", age);
  7. 7
        printf("Months per year: %d\n", monthsPerYear);
  8. 8
        return 0;
  9. 9
    }

Ordena todas las lineas y despues toca Verificar ordenamiento.