GWALNET Logo GWALNET

C Programming

Learn the fundamentals of the C programming language, including syntax, variables, loops, functions, pointers, and memory management. This course provides a strong foundation for structured programming and computer science principles.

Chapter 1

Chapter 1: Introduction to C Language

C is one of the most popular and important programming languages in computer science. It is a general-purpose programming language used to create software, operating systems, applications, embedded systems, and many other programs. C language is known for its: Simple syntax

Chapter 2

Chapter 2: Basic Elements of C Programming

In the previous chapter, you learned about the introduction and basic structure of the C language. In this chapter, you will learn about the basic elements used to write C programs, including variables, constants, data types, input, output, format specifiers, and escape sequences.

Chapter 3

Chapter 3: Operators and Expressions in C Language

In the previous chapters, you learned about the introduction to C, variables, constants, data types, input, and output. In this chapter, you will learn about operators and expressions, which are used to perform calculations, comparisons, and logical operations in C programs.

Chapter 4

Chapter 4: Decision-Making Statements in C

In programming, a program often needs to make decisions based on certain conditions. For example: Is a student eligible to pass? Is a person eligible to vote? Which number is greater? What grade should be assigned based on marks? In C language, decision-making statements allow a program to choose different actions depending on whether a condition is true or false.

Chapter 5

Chapter 5 – Loops in C Language

In programming, we often need to perform the same task multiple times. Writing the same statements again and again would make a program longer and harder to manage. Loops provide a simple way to repeat a set of statements until a particular condition is satisfied. For example, if we want to print numbers from 1 to 10, we could write ten printf() statements. However, using a loop, the same task can be completed with only a few lines of code. In this chapter, you will learn about the different types of loops available in the C language and how to use them effectively.

Chapter 6

Chapter 6 – Arrays in C Language

While writing programs, we often need to store multiple values of the same type. For example, a program may need to store the marks of 50 students or the prices of 20 products. Creating a separate variable for every value would make the program difficult to manage. Arrays provide a convenient way to store multiple values using a single variable name. In this chapter, you will learn what arrays are, how to declare and initialize them, how to access their elements, and how to process arrays using loops.

Chapter 7

Chapter 7 – Strings in C Language

In many programs, we need to work with text such as names, addresses, messages, and sentences. In C language, text is commonly represented using strings. A string is a sequence of characters stored in a character array. Unlike some other programming languages, C does not have a separate built-in string data type. Instead, strings are stored using arrays of the char data type. In this chapter, you will learn how to declare, initialize, input, display, compare, copy, and manipulate strings in C.

Chapter 8

Chapter 8 – Functions in C Language

As programs become larger, writing all the instructions inside the main() function can make the program difficult to understand and maintain. Functions help us divide a program into smaller, organized, and reusable blocks of code. A function can perform a particular task and can be called whenever that task is required. For example, instead of writing the same code for calculating a sum several times, we can create one function and call it whenever needed.

Chapter 9

Chapter 9 – Pointers in C Language

Pointers are one of the most important concepts in C programming. They provide a way to work directly with memory addresses and allow programs to access and modify data indirectly. Pointers are used extensively with arrays, strings, functions, dynamic memory allocation, structures, and many other advanced C programming concepts. Pointers may seem difficult at first, but understanding two basic ideas makes them much easier: Every variable is stored somewhere in memory.

Chapter 10

Chapter 10 – Structures and Unions in C Language

So far, we have learned about variables, arrays, strings, functions, and pointers. Arrays allow us to store multiple values of the same data type. But sometimes a program needs to store different types of information about a single object. For example, information about a student may include: Student ID – integer Name – character array Marks – floating-point value Grade – character Using separate variables for every student can make a program difficult to manage. C provides structures to group related data of different types under one name. C also provides unions, which are similar to structures but use memory differently. In this chapter, you will learn:

Chapter 11

Chapter 11 – File Handling in C Language

In this chapter, you will learn about files, file pointers, opening and closing files, reading and writing text, appending data, character and formatted I/O, binary files, and common file-handling errors.

Chapter 12

Chapter 12 – Dynamic Memory Allocation in C Language

In C programming, memory is an important resource. In earlier chapters, we created variables and arrays whose size was generally determined when the program was compiled. But sometimes the amount of memory required is not known in advance. For example: A program may need to store an unknown number of students. The size of an input may change during execution. A program may need additional memory only when a particular operation is performed. Memory may need to be released when it is no longer required. C provides Dynamic Memory Allocation (DMA) for these situations. Dynamic memory allocation allows a program to request memory during runtime and release it when it is no longer needed. The main functions used for dynamic memory allocation are: malloc() calloc() realloc() free() These functions are declared in: #include <stdlib.h>

Chapter 13

Chapter 13 – Preprocessors and Macros in C Language

The C preprocessor is an important part of the C programming environment. It processes certain instructions in a source file before the compiler performs the normal compilation of the C code. Preprocessor instructions are called preprocessor directives. They generally begin with the # symbol. Some commonly used directives are: #include #define #undef #if #ifdef #ifndef #else #elif #endif Preprocessors are commonly used for: Including header files Creating constants Defining macros Conditional compilation Preventing repeated inclusion of headers Writing configurable and maintainable programs