Introduction To
C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, and it has therefore found lasting use in applications that were previously coded in assembly language.
The main features of C language include low-level access to memory, simple set of keywords, and clean style, these features make C language suitable for system programming like operating system or compiler development.
Many later languages have borrowed syntax/features directly or indirectly from C language.
C was originally developed at Bell Labs by Dennis Ritchie, between 1972 and 1973. It was created to make utilities running on Unix. Later, it was applied to re-implementing the kernel of the Unix operating system[6]. During the 1980s, C gradually gained popularity. Nowadays, it is one of the most widely used programming languages[7][8], with C compilers from various vendors available for the majority of existing computer architectures and operating systems.
Our C language tutorial will take you through the basic, Intermediary and pro level of the language.
Why C Language is so popular?
C language is a very good language to introduce yourself to the programming world, as it is a simple procedural language which is capable of doing wonders.
Programs written in C language takes very less time to execute and almost executes at the speed of assembly language instructions. Initially C language was mainly used for writing system level programs, like designing operating systems, but there are other applications as well which can be very well designed and developed using C language, like Text Editors, Compilers, Network Drivers etc.
Course Structure
Basics
- C Language Introduction
- C Programming Language Standard
- int (1 sign bit + 31 data bits) keyword in C
- Difference between “int main()” and “int main(void)” in C/C++?
- Interesting Facts about Macros and Preprocessors in C
- Compiling a C program:- Behind the Scenes
- Benefits of C language over other programming languages
- Program error signals
- Escape Sequences in C
- Line Splicing in C/C++
- C/C++ Tokens
Variable Declaration, Definition and Scope
- Variables and Keywords in C
- How are variables scoped in C – Static or Dynamic?
- Scope rules in C
- How Linkers Resolve Global Symbols Defined at Multiple Places?
- C Variable Declaration and Scope
- Internal Linkage and External Linkage in C
- Different ways to declare variable as constant in C and C++
- Why variable name does not start with numbers in C ?
- Redeclaration of global variable in C
- Initialization of global and static variables in C
Data Types
- Data Types in C
- Integer Promotions in C
- C Data Types
- Comparison of a float with a value in C
- Is there any need of “long” data type in C and C++?
- What is the size_t data type in C?
- Interesting facts about data-types and modifiers in C/C++
- Difference between float and double in C/C++
- Character arithmetic in C and C++
- Type Conversion in C
Storage Classes
- Storage Classes in C
- Static Variables in C
- Understanding “extern” keyword in C
- What are the default values of static variables in C?
- Understanding “volatile” qualifier in C Set 2 (Examples)
- Const Qualifier in C
- Initialization of static variables in C
- Understanding “register” keyword in C
- C Storage Classes and Type Qualifiers
- Understanding “volatile” qualifier in C Set 1 (Introduction)
Input/Output
- Return values of printf() and scanf() in C/C++
- What is return type of getchar(), fgetc() and getc() ?
- Scansets in C
- puts() vs printf() for printing a string
- What is use of %n in printf() ?
- How to print % using printf()?
- C Input and Output
- What is the difference between printf, sprintf and fprintf?
- Difference between getc(), getchar(), getch() and getche()
- Difference between %d and %i format specifier in C language
- Use of fflush(stdin) in C
- Differentiate printable and control character in C ?
- rand() and srand() in C/C++
Operators
- Operators in C Set 1 (Arithmetic Operators)
- Operators in C Set 2 (Relational and Logical Operators)
- Bitwise Operators in C/C++
- Interesting facts about Operator Precedence and Associativity in C
- Evaluation order of operands
- Comma in C and C++
- sizeof operator in C
- Operands for sizeof operator
- A comma operator question
- Result of comma operator as l-value in C and C++
- Order of operands for logical operators
- Increment (Decrement) operators require L-value Expression
- Precedence of postfix ++ and prefix ++ in C/C++
- Modulus on Negative Numbers
- C/C++ Ternary Operator – Some Interesting Observations
- Difference between ++*p, *p++ and *++p
- Results of comparison operations in C and C++
- Anything written in sizeof() is never executed in C
- Difference between strlen() and sizeof() for string in C
- # and ## Operators in C
Preprocessor
- Write a C macro PRINT(x) which prints x
- Variable length arguments for Macros
- Multiline macros in C
- CRASH() macro – interpretation
- The OFFSETOF() macro
- Branch prediction macros in GCC
- Diffference between #define and const in C?
- A C Programming Language Puzzle
- What’s difference between header files “stdio.h” and “stdlib.h” ?
- How to print a variable name in C?
- Constants in C
- How a Preprocessor works in C?
- C/C++ Preprocessor directives Set 2
- isgraph() C library function
- How to write your own header file in C?
- tmpnam() function in C
- _Generic keyword in C
- C Library math.h functions
- typedef versus #define in C
- strftime() function in C/C++
- exec family of functions in C
Arrays & Strings
- Strings in C
- Arrays in C Language Set 2 (Properties)
- Do not use sizeof for array parameters
- Initialization of variables sized arrays in C
- Are array members deeply copied?
- What is the difference between single quoted and double quoted declaration of char array?
- Initialization of a multidimensional arrays in C/C++
- Write one line functions for strcat() and strcmp()
- What’s difference between char s[] and char *s in C?
- gets() is risky to use!
- C function to Swap strings
- Storage for Strings in C
- Difference between pointer and array in C?
- How to dynamically allocate a 2D array in C?
- How to pass a 2D array as a parameter in C?
- How to write long strings in Multi-lines C/C++?
- What are the data types for which it is not possible to create an array?
- Variable Length Arrays in C and C++
- A shorthand array notation in C for repeated values
- Accessing array out of bounds in C/C++
- strcpy in C/C++
- strcmp() in C/C++
- strdup() and strndup() functions in C/C++
- How to pass an array by value in C ?
- ispunct() function in C
- strspn() function in C
- isalpha() and isdigit() functions in C/C++ with example
Control Statements
- Data type of case labels of switch statement in C++?
- For Versus While
- A nested loop puzzle
- Interesting facts about switch statement in C
- Difference between while(1) and while(0) in C language
- goto statement in C/C++
- Continue Statement in C/C++
- Break Statement in C/C++
- Using range in switch case in C/C++
Functions
- Importance of function prototype in C
- Functions that are executed before and after main() in C
- return statement vs exit() in main()
- How to Count Variable Numbers of Arguments in C?
- What is evaluation order of function parameters in C?
- Does C support function overloading?
- How can I return multiple values from a function?
- What is the purpose of a function prototype?
- Static functions in C
- exit(), abort() and assert()
- Implicit return type int in C
- What happens when a function is called before its declaration in C?
- _Noreturn function specifier in C
- Predefined Identifier __func__ in C
- Callbacks in C
- Nested functions in C
- Parameter Passing Techniques in C/C++
- Power Function in C/C++
- tolower() function in C
- time() function in C
Pointers
- Double Pointer (Pointer to Pointer) in C
- Why C treats array parameters as pointers?
- Output of the program Dereference, Reference, Dereference, Reference….
- An Uncommon representation of array elements
- How to declare a pointer to a function?
- Pointer vs Array in C
- void pointer in C / C++
- NULL pointer in C
- Function Pointer in C
- What are near, far and huge pointers?
- Generic Linked List in C
- restrict keyword in C
- Difference between const char *p, char * const p and const char * const p
- Pointer to an Array Array Pointer
Enum, Struct and Union
- Enumeration (or enum) in C
- Structures in C
- Union in C
- Struct Hack
- Structure Member Alignment, Padding and Data Packing
- Operations on struct variables in C
- Bit Fields in C
- Structure Sorting (By Multiple Rules) in C++
- Flexible Array Members in a structure in C
- Difference between Structure and Union in C
- Anonymous Union and Structure in C
- Compound Literals in C
Memory Management
File Handling
- fseek() vs rewind() in C
- EOF, getc() and feof() in C
- fopen() for an existing file in write mode
- Read/Write structure to a file in C
- fgets() and gets() in C language
- Basics of File Handling in C
- fsetpos() (Set File Position) in C
- tmpfile() function in C
- fgetc() and fputc() in C
- fseek() in C/C++ with example
- ftell() in C with example
- lseek() in C/C++ to read the alternate nth byte and write it in another file
- C program to delete a file
- C Program to merge contents of two files into a third file
- C Program to print contents of file
Puzzles
- C Program to print numbers from 1 to N without using semicolon?
- To find sum of two numbers without using any operator
- How will you show memory representation of C variables?
- Condition To Print “HelloWord”
- Change/add only one character and print ‘*’ exactly 20 times
- What is the best way in C to convert a number to a string?
- Program to compute Log n
- Print “Even” or “Odd” without using conditional statement
- How will you print numbers from 1 to 100 without using loop?
- Write a C program to print “Geeks for Geeks” without using a semicolon
- Write a one line C function to round floating point numbers
- Implement Your Own sizeof
- How to count set bits in a floating point number in C?
- How to find length of a string without string.h and loop in C?
- Implement your own itoa()
- Write a C program that does not terminate when Ctrl+C is pressed
- How to measure time taken by a function in C?
- Print a long int in C using putchar() only
- Convert a floating point number to string in C
- How to write a running C code without main()?
- C program to print characters without using format specifiers
- C program to print a string without any quote (singe or double) in the program
- Print “Hello World” in C/C++ without using any header file
Misc
- Quine – A self-reproducing program
- Complicated declarations in C
- Use of bool in C
- Sequence Points in C Set 1
- Optimization Techniques Set 2 (swapping)
- ASCII NUL, ASCII 0 (‘0’) and Numeric literal 0
- Little and Big Endian Mystery
- Comparator function of qsort() in C
- Program to validate an IP address
- Multithreading in C
- Assertions in C/C++
- fork() in C
- Concept of setjump and longjump in C
- pthread_cancel() in C with example
- pthread_equal() in C with example
- pthread_self() in C with Example
- Local Labels in C
- lvalue and rvalue in C language
- Get the stack size and set the stack size of thread attribute in C
- Difference between fork() and exec()
- Errors in C/C++
- Why is C considered faster than other languages ?
- Incompatibilities between C and C++ codes
- Convert C/C++ code to assembly language
- Error Handling in C programs
- Executing main() in C/C++ – behind the scene
- Hygienic Macros : An Introduction
- Interesting Facts in C Programming
- Function Interposition in C with an example of user defined malloc()
- Macros vs Functions
- Write your own memcpy() and memmove()