0% found this document useful (0 votes)
7 views3 pages

C Programming Basics and Applications

C is a general-purpose procedural programming language developed by Dennis Ritchie in 1972, primarily for UNIX operating system development. The tutorial covers essential C programming concepts, including header files, installation requirements, differences between C and C++, and various applications of C. It also explains the C compilation process, identifiers, functions, dynamic memory allocation, file reading, and pointers.

Uploaded by

Pratheeksha R
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

C Programming Basics and Applications

C is a general-purpose procedural programming language developed by Dennis Ritchie in 1972, primarily for UNIX operating system development. The tutorial covers essential C programming concepts, including header files, installation requirements, differences between C and C++, and various applications of C. It also explains the C compilation process, identifiers, functions, dynamic memory allocation, file reading, and pointers.

Uploaded by

Pratheeksha R
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming Tutorial

C is a general-purpose procedural programming language initially developed by Dennis Ritchie in


1972 at Bell Laboratories of AT&T; Labs.

It was initially used for the development of UNIX operating system.

include
int main(void)
{
// This prints "Hello World"
printf("Hello World");
return 0;
}

Header Files Inclusion - Line 1 [include ]


The first component is the Header files in a C program. A header file is a file with extension .h which
contains C function declarations and macro definitions to be shared between several source files.
All lines that start with # are processed by a preprocessor.
Some of the C Header files:
- stdio.h - Defines core input and output functions
- string.h - Defines string handling functions
- math.h - Defines common mathematical functions.

Install C in Your Computer


Installing C requires two software:
1. C Compiler: converts your C code into executable programs.
2. Text Editor (IDE): for editing and writing C code.

Install C Compiler
For Windows: Use MinGW (Minimalist GNU for Windows).

Difference Between C and C++


C++ was created to add OOP to C. Differences:
- Paradigm: C (Procedural), C++ (Procedural + OOP + Generic)
- OOP: Not in C, present in C++
- Memory Management: C (malloc/free), C++ (new/delete + manual)
- Function/Operator Overloading: Only in C++
- Access Control: Only in C++
Application of C Language
- OS development (Windows, Linux, macOS)
- Embedded systems (washing machines, printers)
- Game engines (Doom engine)
- Compilers/interpreters (CPython)
- Database engines (MySQL)
- IoT devices (home automation)
- Lightweight apps (Notepad++)

C is a general-purpose procedural programming language developed by Dennis Ritchie in 1972 at


Bell Labs to build the UNIX operating system. It provides low-level memory access, high
performance, and portability, making it ideal for system programming.

C Compilation Process (hello.c → executable)


1. Pre-processing → expands macros, headers (output: hello.i)
2. Compilation → C code → assembly (hello.s)
3. Assembling → assembly → machine code (hello.o)
4. Linking → combines object files + libraries → executable

Identifiers in C
Names given to variables, functions, arrays, structures, etc.

Keywords in C (32 total)


Examples: int, float, char, if, else, while, for, return, void, struct, typedef, union, static, const, break,
continue.

Type Conversion
- Implicit: automatic (int → float)
- Explicit: manual (casting)

Functions
- Pass by value
- Pass by pointers
- Recursion
- Inline functions

Structures vs Classes
- Structures: C (no OOP features)
- Classes: C++ (support OOP)
Unions in C
Like structures, but all members share the same memory location. Only one value stored at a time.

Enumerations in C
enum name { item1, item2, ... }; assigns names to integers. Default starts from 0.

Dynamic Memory Allocation (DMA)


Functions:
- malloc(): uninitialized memory
- calloc(): initialized to 0
- realloc(): resize memory
- free(): release memory

File Reading in C
- fgetc(): character by character
- fgets(): line by line
- fscanf(): formatted input
- fread(): binary block

Pointers in C
- Store memory address of another variable
- Use * for dereference, & for address-of
- Useful for DMA, efficiency, and data structures

C++ Concepts
- Operator Overloading: lets operators work with user-defined objects.
- Virtual Functions: with virtual → correct function called at runtime (polymorphism). Without →
always calls base class version.

You might also like