C programming
C for electronics and computer engineering students, following Tom's units and the Ministry of Education curriculum (11.9006). Animated presentations, written lessons and practice questions with full answers, in English with key words in Hebrew.
Level: Grade 13, practical engineers. No programming experience needed
Start the course- Unit 1All units
Introduction to C
What programming and an algorithm are, from machine code to C and why C was born, and the first C program in Visual Studio.
- 1What programming isProgramming is exact, step-by-step instructions. Three algorithms from class (tea, a house, a text message), what makes a list an algorithm, and how an idea becomes a result.slideshow45 min
- 2What is C?Machine code, assembly and high-level languages, the compiler and the portability problem, how C was born with Unix at Bell Labs, and where C is used today.slideshow90 min
- 3Your first C programA Visual Studio 2022 lab: an Empty Project and main.c, the Hello, C! program line by line, save, build and run, repairing the first error, a breakpoint and a team mission.slideshow90 min
- 4Practice: Introduction to C20 questions: algorithms to write and repair, the language layers and the compiler, and Visual Studio programs to build, run and repair. Every answer is hidden until you open it.45 min
- Unit 2All units
Variables and arithmetic
Store data, transform it, report the result: variables and their types, assignment and trace tables, and arithmetic in C with integer division, casting and the remainder.
- 1Variables and typesA variable is a named place in memory with a type and a value. Declaration, int, double and char, the type families, unsigned and const, a first look at arrays and strings, and how to choose types and names.slideshow90 min
- 2Assignment and tracingDeclare, initialize, assign, update. = stores the value on the right in the variable on the left. Trace tables line by line, the value nobody set, and swapping two values with temp.slideshow45 min
- 3Arithmetic in CExpressions and the five operators, the order C uses, integer division, casting and the remainder %. Seconds into minutes, the digits of a number, the power program, a bug hunt, and the battery receipt mission.slideshow90 min
- 4Practice: variables and arithmeticTom's exercises for the unit: choosing types and names, tracing, precedence, integer division and remainder, the calculation programs from the lessons, the battery receipt mission, and workbook questions 1-30.90 min
- Unit 3All units
printf and scanf
Talking with the user: printf shows values in the layout you choose, and scanf reads what the user types into variables.
- 1printf: formatted outputHow printf reads its format string from left to right: copied text, escape sequences, %d %f %c %%, several values in one call, and width and precision.slideshow90 min
- 2scanf: reading inputRead values from the keyboard into variables: & and the address, the prompt-read-echo pattern, %lf for double, a space before %c after a number, the C4996 error in Visual Studio, and a complete intake ticket.slideshow90 min
- 3Practice: printf and scanfTom's printf and scanf exercises: predict the output, format a label, read and echo values, the board record mission, and repairing broken scanf and printf code (workbook questions 31-34).45 min
- Unit 4All units
Conditions and decisions
How a program chooses what to do: 0 is false and any other value is true, relational operators, if, if...else and else-if chains, testing at the boundary, and combining conditions with &&, || and !.
- 1True, false and comparisonsHow C answers a question: 0 is false and any other value is true. The six relational operators, reading a comparison as a question, and the bug of writing = instead of ==.slideshow45 min
- 2if, else and else-ifA single if that runs a block or skips it, if...else that picks one of two branches, and an else-if chain that stops at the first true condition. Tracing programs and testing at the boundary.slideshow90 min
- 3Combining conditions: &&, || and !Logical operators and their truth tables, a range check with &&, alternatives with ||, NOT with !, parentheses, why 0 <= score <= 100 fails in C, and short-circuit evaluation. Final task: a number analyzer.slideshow90 min
- 4Practice: conditions and decisionsTom's 32 workbook questions on conditions: truth values and comparisons, single if, if...else, else-if chains, compound conditions with && || and !, tracing, and debugging. Every answer is hidden until you open it.90 min
- Unit 5All units
Advanced decisions and test design
The chamber controller that failed at exactly 80 °C: nested if, the dangling else and branch order, switch and fall-through, the conditional operator ?:, decision tables, and tests below, at and above every boundary.
- 1Nested decisions and boundary testsShort-circuit evaluation, nested if, the dangling else, branch order, decision tables, and tests below, at and above every boundary.slideshow90 min
- 2switch and the conditional operatorswitch jumps to the case that matches and runs on until break; grouped cases; why switch cannot test ranges; choosing a structure; and ?:, which evaluates only the value it chooses.slideshow90 min
- 3Test design: certify the chamber controllerThe full controller: a switch picks the limit, an if chain picks the state. Decision tables, repairs proved by a failing test, reading a test log, acceptance tests and the team mission.slideshow90 min
- 4Practice: advanced decisions and test designThe 14 challenges and 32 coding problems of unit 5: tracing, fall-through, the conditional operator, boundary tests, decision tables, and complete programs. Every answer is hidden until you open it.90 min
- Unit 6All units
Loops
while, for and do...while loops, trace tables and boundaries, the lab exam patterns on a sentinel loop (counting, summing, average, max and min, a companion value), break and continue, nested loops, and a team lab: the battery sampler.
- 1The while loopThe four parts of every loop, while line by line with a trace table, the final failed test, zero iterations, the infinite loop, boundaries, and reading input until a sentinel.slideshow90 min
- 2Loop patternsThe lab exam patterns on a sentinel loop: counting, counting with a condition, summing, summing with a condition, the average, max and min, and max with a companion value.slideshow90 min
- 3for and do...whiledo...while that runs at least once, input validation and a menu; the for loop, the three parts of its header and the run order, boundaries, and how to choose a loop.slideshow90 min
- 4break, continue and nested loopsbreak that ends a loop, continue that skips one iteration, a loop inside a loop, taking a number apart digit by digit (lab experiments 8 and 9), and the team lab: the battery sampler with acceptance tests.slideshow90 min
- 5Practice: LoopsTom's 32 questions for unit 6: choosing a loop, tracing, completing code, sentinel patterns, break and continue, nested loops, and the battery sampler; plus lab experiments 2, 4 and 8.90 min
- Unit 7All units
Functions
A function does one named job: the call, arguments and parameters, the return value, prototype and definition. What happens in memory during a call (frames, pass by value, local variables), contracts and boundary tests, and a charging station controller built from small functions.
- 1Functions and callsWhy functions help, how a call sends an argument and gets a value back, the prototype, the call and the definition, and a complete program traced line by line.slideshow90 min
- 2Parameters, return and local variablesWhat happens in memory during a call: stack frames, returning a value or void, parameters that receive copies, trace tables, and local variables that disappear after return.slideshow45 min
- 3Contracts, tests and decompositionWrite the contract of a function, test it on its boundaries, repair a broken function, split a program into one-job functions, and build the charging station controller.slideshow90 min
- 4Practice: FunctionsThe 30 questions of unit 7: 14 short checks and 16 complete programs, from the first call to a tested charging station controller. Every answer is hidden until you open it.
- Unit 8All units
Arrays and strings
Ten ADC channels in one array: indexes and bounds, walking the array with a loop, sum, average, minimum, maximum and counts, and strings as char arrays that end with the null terminator. Prepares lab experiments 10, 16 and 17.
- 1One-dimensional arraysMany sensor readings under one name: declaring and initializing an array, index and element, length and last index, walking the array with a loop, the off-by-one fault, reading input into an array, and walking backward, over a range and with a step.slideshow90 min
- 2Sensor data: sum, average, minimum, maximumComputing with an array of readings: the sum accumulator, the average with a cast, minimum and maximum from the first element, counting by a rule and counting occurrences, changes between neighbours, linear search, an array as a function parameter, a first sorting pass, and how to test it all. Prepares lab experiments 10 and 17.slideshow90 min
- 3Strings and charactersA C string is a char array that ends with the null terminator: capacity, walking a string to its end, length versus capacity, reading a line with fgets, the functions strlen, strcmp, strcpy and strcat, and classifying characters (lab experiment 16).slideshow90 min
- 4Practice: arraysQuestions 1 to 30 of unit 8: 14 short checks and 16 complete programs on indexes, bounds, sums, averages, extremes, counts and the ten-channel laboratory (lab experiments 10 and 17). Every answer is hidden until you open it.90 min
- 5Practice: traversal and stringsQuestions 31 to 46 of unit 8: strings in memory, traversal patterns (forward, backward, a range, a step, neighbours), string programs with fgets and string.h, character classification (lab experiment 16), a search function and a first bubble sort. Every answer is hidden until you open it.90 min
- Unit 9All units
Two-dimensional arrays
Matrices in C: rows and columns, indexes and bounds, nested loops that visit every cell, row and column totals, the maximum and its position, the two diagonals and lab experiment 11, transpose, memory layout and functions.
- 1Rows, columns and nested loopsDeclare and initialize a matrix, reach any cell with a row index and a column index, stay inside the bounds, and visit every cell with two nested loops: read with scanf and print in neat columns.slideshow90 min
- 2Totals, maximum and countingThe same two loops with different jobs: the sum of all cells, the sum of one row and of one column, an average for every row, the maximum and where it is, and counting the cells that pass a test.slideshow90 min
- 3Diagonals, transpose and functionsSquare matrices and their two diagonals, lab experiment 11 (are the diagonals of a 10 × 10 array equal?), transpose, how a matrix sits in memory, passing a matrix to a function, common mistakes and how much work each operation takes.slideshow90 min
- 4Practice: 2D arrays, 30 short questionsTom's 30 short questions on two-dimensional arrays: sizes and indexes, nested loops, sums, diagonals, bounds, initialization, transpose and sensor grids. Every answer is hidden until you open it.45 min
- 5Practice: 2D arrays, programs and challengesTom's 40-question set on two-dimensional arrays: 12 fundamentals, 18 complete programs (sums, maximum, diagonals, transpose, matrix operations, searching) and 10 algorithm challenges. Every answer has the idea and a complete C17 program that compiles in Visual Studio.90 min