x

C Programming Tutorial

Prev     Next

C Programming is an ANSI/ISO standard and powerful programming language for developing real time applications. C programming language was invented by Dennis Ritchie at the Bell Laboratories in 1972. It was invented for implementing UNIX operating system. C is most widely used programming language even today. All other programming languages were derived directly or indirectly from C programming concepts. This C tutorial explains all basic concepts in C like history of C language, data types, keywords, constants, variables, operators, expressions, control statements, array, pointer, string, library functions, structures and unions etc.


This C programming tutorial is designed for the new learners, students and also for the corporate level developers who want to learn and refresh their C programming skills.

Start C programming tutorial

C programming history:

The C programming language is a structure oriented programming language, was developed at Bell Laboratories in 1972 by Dennis Ritchie. C programming language features were derived from an earlier language called “B” (Basic Combined Programming Language – BCPL). C language was invented for implementing UNIX operating system….more…

C programming basics:

Steps to be followed for any C program to create and get the output are explained . This is common to all C programs and there is no exception, whether its a very small C program or very large program. Structure of a C program is defined by a set of rules called protocol, to be followed by programmer while writing a C program…more…

C – printf and scanf:

printf() and scanf() functions are inbuilt library functions in C which are available in the C library by default. These functions are declared and related macros are defined in “stdio.h” which is a header file. We have to include “stdio.h” file as shown in below C program to make use of these printf() and scanf() library functions….more…

C – Data Types:

C data types are defined as the data storage format that a variable can store a data to perform a specific operation. Data types are used to define a variable before using in a program. Size of variable, const and array are determined by data types. There are four data types in the C language. They are….more…

C – Tokens and keywords:

C tokens, Identifiers and Keywords are the basics in a C program. All are explained in this page with definition and simple example programs. C tokens are the basic building blocks in C language which are constructed together to write a C program. Each program element in a C program is given a name called identifiers….more…

C – Constants:

C Constants are also like normal variables. But, the only difference is, their values can’t be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals. Constants may be belonging to any of the data type….more…

C – Variables:

C variable is a named location in a memory where a program can manipulate the data. This location is used to hold the value of the variable. The value of the C variable may get changed in the program. The C variable might be belonging to any of the data types like int, float, char etc….more…

C – Operators and Expressions:

The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators, functions, constants and variables are combined together to form expressions….more…

C – Decision Control statements:

In decision control statements (C – if else and nested if), group of statement is executed when the condition is true.  If the condition is false, then, else part statements are executed. In C programming, there are 3 types of decision making control statements in C language. They are….more…

C – Loop control statements:

Loop control statements in C programming are used to perform looping operations until the given condition is true. Control comes out of the loop statements once the condition becomes false. There are 3 types of loop control statements in C language. They are….more…

C – Case control statements:

The statements which are used to execute only specific block of statements in a series of blocks are called case control statements. There are 4 types of case control statements in C programming. They are 1) switch 2) break 3) continue 4) goto….more…

C – Type Qualifiers:

The keywords which are used to modify the properties of a variable are called type qualifiers. There are two types of qualifiers available in C programming. They are 1) const 2) volatile. Constants are also like normal variables….more…

C – Storage Class Specifiers:

Storage class specifiers in C programming tell the compiler where to store a variable, how to store the variable, what is the initial value of the variable and the lifetime of the variable. There are 4 storage class specifiers available in C language. They are….more…

C – Array:

C Array is a collection of variables belongings to the same data type. You can store group of data of the same data type in an array. There are 2 types of arrays in C programming. They are 1) One dimensional array 2) Multidimensional array….more…

C – String:

C Strings are nothing but array of characters ended with null character (‘\0’). This null character indicates the end of the string. In C programming, strings are always enclosed by double quotes. Whereas, character is enclosed by single quotes in C…more…

C – Pointer:

C Pointer is a variable that stores/points the address of the other variable. C Pointer is used to allocate memory dynamically,  i.e. at run time. The variable might be any of the data types such as int, float, char, double, short etc. Normal variable stores the value, whereas pointer variable stores the address of the variable….more…

C – Functions:

Functions in C programming are basic building blocks in a program. All C programs are written using functions to improve re-usability, understandability and to keep track of them. A large C program is divided into basic building blocks called C function. C function contains set of instructions enclosed by “{  }” which performs specific….more… 

C – Library functions:

Library functions in C language are inbuilt functions which are grouped together and placed in a common place called a library. Each library function in C programming language performs a specific operation. We can make use of these library functions to get the pre-defined output instead of writing our own code to get those outputs….more… 


C – Command line arguments:

main() function of a C program accepts arguments from command line or from other shell scripts by following commands. They are 1. argc 2. argv[]. In real time application, it will happen to pass arguments to the main program itself.  These arguments are passed to the main () function while executing binary file from command line….more… 

C – Variable length argument:

Variable length arguments in C programming are an advanced concept offered by C99 standard. In C89 standard, fixed arguments only can be passed to the functions. When a function gets the number of arguments that changes at run time, we can go for a variable length arguments. It is denoted as … (3 dots)….more… 

List of inbuilt functions in C programming:

1. C – Arithmetic functions:

Inbuilt C programming functions which are used to perform mathematical operations in a program are called Arithmetic functions. Example program for abs(), floor(), round(), ceil(), sqrt(), exp(), log(), sin(), cos(), tan(), pow() and trunc() functions are….more… 

2. C – Int, char validation functions:

There are many inbuilt functions in C language which are used to validate the data type of given variable and to convert upper to lower case and lower to upper case are given below with description….more… 

3. C – Buffer manipulation function:

Buffer manipulation functions in C programming work on the address of the memory block rather than the values inside the address. Example programs for memset(), memcpy(), memmove(), memcmp(), memicmp() and memchr() functions are….more… 

4. C – Time related functions:

Time functions in C are used to interact with system time routine and formatted time outputs are displayed. Example programs for the time functions are….more… 

5. C – Dynamic memory allocation:

The process of allocating memory during program execution is called dynamic memory allocation. C language offers 4 dynamic memory allocation functions. They are, malloc(), calloc(), realloc() and free()….more… 

6. C – type casting functions:

Typecasting concept in C language is used to modify a variable from one date type to another data type. New data type should be mentioned before the variable name or value in brackets which to be typecast….more… 

7. C – Miscellaneous functions:

Descriptions and example programs for C environment functions such as getenv(), setenv(), putenv() and other functions perror(), random() and delay() are….more… 

C – Structure:

C Structure is a collection of different data types which are grouped together and each element in a C structure is called member. If you want to access structure members in C, structure variable should be declared….more… 

C – Typedef:

Typedef is a keyword that is used to give a new symbolic name for the existing name in a C program. This is same like defining alias for the commands….more… 

C – Union:

C Union is also like structure, i.e. collection of different data types which are grouped together. Each element in a union is called member. Union and structure in C  are same in concepts, except allocating memory for their members….more… 

C – Preprocessor directives:

Before a C program is compiled in a compiler, source code is processed by a program called preprocessor. This process is called preprocessing. Commands used in preprocessor are called preprocessor directives and they begin with “#” symbol….more… 

C tutorial with example programs:

C – for, while and do while Example Programs
C – switch, break, continue and goto Example Programs
C – auto, static, extern and register Example Programs
C  – array Example Programs
C – string Example Programs
C – pointer Example Programs
C – function Example Programs
C – structure Example Programs
C – typedef Example Programs
C – union Example Programs
C – typecast Example Programs
C – undef and #define Example Programs
C – command line argument Example Programs
C – variable length argument Example Programs
C – malloc, calloc, realloc and free Example Programs

Real Time C Programming examples:

  • When you complete this c programming tutorial, you can able to write real time C programs by your own. We are walking you through all topics in this c programming tutorial which are explained clearly even for very beginners for C programming.
  • We have given few real time application programs with output in this C tutorial.

C programming applications for reference:

1. C program example – Real time Calculator program
2. C program example – Real time Bank Application program

Reference C programming E-books & research papers:

  • ANSI 89 – American National Standards Institute, American National Standard for Information Systems Programming Language C, 1989.
  • Kernighan 78 – B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall: Englewood Cliffs, NJ, 1978. Second edition, 1988.
  • Thinking 90 – C* Programming Guide, Thinking Machines Corp. Cambridge Mass., 1990.

Prev     Next



Like it? Please Spread the word!