Skip to main content

Beginner-Friendly Topic

Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!

Lesson 10 of 10

Practice & Quiz - C Fundamentals

Test your understanding of C compilation, data types, constants, I/O, and type conversion with a practical exercise and 5 quiz questions.

10 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Practical Exercise

Practical Exercise
/* sizes.c - explore primitive type sizes and type conversion */
#include <stdio.h>
#include <stdint.h>
#include <limits.h>

int main(void) {
    /* Portable exact-width types */
    printf("int8_t  : %zu byte,  range [%d, %d]
", sizeof(int8_t),  INT8_MIN,  INT8_MAX);
    printf("uint8_t : %zu byte,  range [0, %u]
",  sizeof(uint8_t), UINT8_MAX);
    printf("int32_t : %zu bytes
", sizeof(int32_t));
    printf("int64_t : %zu bytes
", sizeof(int64_t));

    /* Platform sizes */
    printf("
char=%zu  int=%zu  long=%zu  ptr=%zu
",
           sizeof(char), sizeof(int), sizeof(long), sizeof(void *));

    /* Type conversion trap */
    int   a = 7, b = 2;
    double wrong   = a / b;          /* 3.0 -- int division first */
    double correct = (double)a / b;  /* 3.5 -- cast before divide */
    printf("7/2 int-div  = %.1f
", wrong);
    printf("7/2 cast-div = %.1f
", correct);

    /* Signed/unsigned comparison trap */
    int si = -1;
    unsigned int ui = 1;
    printf("(-1 < 1u) = %d  (expect 0 -- -1 becomes UINT_MAX)
", si < ui);

    return 0;
}
/* gcc -Wall -std=c99 sizes.c -o sizes && ./sizes */

Module Quiz

Module Quiz
Question 1 of 5

What does `#include <stdio.h>` instruct the preprocessor to do?

Tip

Tip

Practice Practice Quiz C Fundamentals in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

Core Foundations: Architecture, Types, Operators, Namespaces, Constants & Multi-File Builds

Practice Task

Note

Practice Task - (1) Write a working example of Practice Quiz C Fundamentals from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Common Mistake

Warning

A common mistake with Practice Quiz C Fundamentals is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready c code.

Topics in This Module

0/10 done