C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972. In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard. The UNIX operating system, the C compiler, and essentially all UNIX application programs have been written in C. C has now become a widely used professional language for various reasons:

  1.  Easy to learn
  2.  Structured language
  3.  It produces efficient programs
  4.  It can handle low-level activities
  5.  It can be compiled on a variety of computer platforms

Facts about C

 C was invented to write an operating system called UNIX.
 C is a successor of B language which was introduced around the early 1970s.

 The language was formalized in 1988 by the American National Standard Institute (ANSI).
 The UNIX OS was totally written in C.
 Today C is the most widely used and popular System Programming Language
.  Most of the state-of-the-art software have been implemented using C.

 Today's most popular Linux OS and RDBMS MySQL have been written in C.

Why Use C?

C was initially used for system development work, particularly the programs that make-up the operating system. C was adopted as a system development language because it produces code that runs nearly as fast as the code written in assembly language. Some examples of the use of C might be:
 Operating Systems  Language Compilers
 Assemblers
 Text Editors
 Print Spoolers
 Network Drivers
 Modern Programs
 Databases
 Language Interpreters
 Utilities
C Programs A C program can vary from 3 lines to millions of lines and it should be written into one or more text files with extension ".c"; for example, hello.c. You can use "vi", "vim" or any other text editor to write your C program into a file. This tutorial assumes that you know how to edit a text file and how to write source code inside a program file. C Programming
Try it Option Online You really do not need to set up your own environment to start learning C programming language. Reason is very simple, we already have set up C Programming environment online, so that you can compile and execute all the available examples online at the same time when you are doing your theory work. This gives you confidence in what you are reading and to check the result with different options. Feel free to modify any example and execute it online. Try following example using our online compiler option available at http://www.compileonline.com/.
#include <stdio.h>
int main()
/* my first program in C */
printf("Hello, World! \n");

return 0;

For most of the examples given in this tutorial, you will find the Try it option in our website code sections at the top right corner that will take you to the online compiler. So just make use of it and enjoy your learning. Local Environment Setup If you want to set up your environment for C programming language, you need the following two software tools available on your computer,
(a) Text Editor and
(b) The C Compiler.

Text Editor This will be used to type your program. Examples of a few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.


The name and version of text editors can vary on different operating systems.
For example,
Notepad will be used on Windows, and vim or vi can be used on Windows as well as on Linux or UNIX.
The files you create with your editor are called the source files and they contain the program source codes.
The source files for C programs are typically named with the extension ".c". Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, compile it and finally execute it.
The C Compiler The source code written in source file is the human readable source for your program.
It needs to be "compiled" into machine language so that your CPU can actually execute the program as per the instructions given. The compiler compiles the source codes into final executable programs.
The most frequently used and free available compiler is the GNU C/C++ compiler, otherwise you can have compilers either from HP or Solaris if you have the respective operating systems. The following section explains how to install GNU C/C++ compiler on various OS. m We keep mentioning C/C++ together because GNU gcc compiler works for both C and C++ programming languages. Installation on UNIX/Linux If you are using Linux or UNIX, then check whether GCC is installed on your system by entering the following command from the command line:
$ gcc -v
If you have GNU compiler installed on your machine, then it should print a message as follows: Using built-in specs.
Target: i386-redhat-linux Configured with: ../configure --prefix=/usr ....... Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
If GCC is not installed, then you will have to install it yourself using the detailed instructions available at http://gcc.gnu.org/install/. This tutorial has been written based on Linux and all the given examples have been compiled on the Cent OS flavor of the Linux system.
Installation on Mac OS If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple's web site and follow the simple installation instructions. Once you have Xcode setup, you will be able to use GNU compiler for C/C++. Xcode is currently available at developer.apple.com/technologies/tools/.
Installation on Windows To install GCC on Windows, you need to install MinGW. To install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program, which should be named MinGW-.exe. While installing MinGW, at a minimum, you must install gcc-core, gcc-g++, binutils, and the MinGW runtime, but you may wish to install more. Add the bin subdirectory of your MinGW installation to your PATH environment variable, so that you can specify these tools on the command line by their simple names. After the installation is complete, you will be able to run gcc, g++, ar, ranlib, dlltool, and several other GNU tools from the Windows command line.
Instalation of codeblocs in video lecture

Tokens in C

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens:
  1. Keyword
  2. Identifier
  3. Constant
  4. Operator
  5. Special symbols
  6. String


kleywords are pre-defind or reserved words in a programming language. Each keyword is meant to perform a specific function in a program compiler , they can't be used as variable names beacause by doing so , we are ryibng to assign a new meaning to the keyword which is not allowed . You cannot redefine keywords s. howver , you can specigy test to be substitute for keywords before compilation by usiung c/c++ pre processor directives. c language supports 32 keywords which are given

auto else long switch
break enum register typedef
case extern retur union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed
double |


A C identifier is a name used to identify a variable, function, or any other userdefined item. An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9). C does not allow punctuation characters such as @, $, and % within identifiers.
C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers:

There are certain rules that should be followed while naming c identifiers:

  1. They must begin with a letter or underscore(_).
  2. They must consist of only letters, digits, or underscore. No other special character is allowed.
  3. It should not be a keyword.
  4. It must not contain white space.
  5. It should be up to 31 characters long as only first 31 characters are significant.
  6. Some examples of c identifiers:

mohd zara abc move_name a_123
myname50 _temp j a23b9 retVal

printf("Hello, World! \n");
The individual tokens are:
"Hello, World! \n"


Constants are also like normal variables. But, only difference is, their values can not be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals. Constants may belong to any of the data type.Syntax:

const data_type variable_name; (or) const data_type *variable_name;

Types of Constants:

  1. Integer constants – Example: 0, 1, 1218, 12482
  2. Real or Floating point constants – Example: 0.0, 1203.03, 30486.184
  3. Octal & Hexadecimal constants – Example: octal: (013 )8 = (11)10, Hexadecimal: (013)16 = (19)10
  4. Character constants -Example: ‘a’, ‘A’, ‘z’
  5. String constants -Example: “cstutorial”


Operators are symbols that triggers an action when applied to C variables and other objects. The data items on which operators act upon are called operands.

Depending on the number of operands that an operator can act upon, operators can be classified as follows:

Unary Operators

: Those operators that require only single operand to act upon are known as unary operators.For Example increment and decrement operators

Binary Operators:

Those operators that require two operands to act upon are called binary operators. Binary operators are classified into :
  1. Arithmetic operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operators
  5. Conditional Operators
  6. Bitwise Operators

Ternary Operators:

These operators requires three operands to act upon. For Example Conditional operator(?:).

5.Special characters

he following special symbols are used in C having some special meaning and thus, cannot be used for some other purpose.[] () {}, ; * = #


Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.


These special symbols are used to indicate function calls and function parameters.


These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.

comma (, ):

It is used to separate more than one statements like for separating parameters in function calls.

semi colon :

It is an operator that essentially invokes something called an initialization list.

asterick (*):

It is used to create pointer variable.

assignment operator:

It is used to assign values.

pre processor(#):

The preprocessor is a macro processor that is used automatically by the compiler to transform your program before actual compilation.


Strings are nothing but an array of characters ended with a null character (‘\0’).This null character indicates the end of the string. Strings are always enclosed in double quotes. Whereas, a character is enclosed in single quotes in C and C++.Declarations for String:

char string[20] = {‘g’, ’e’, ‘e’, ‘k’, ‘s’, ‘f’, ‘o’, ‘r’, ‘g’, ’e’, ‘e’, ‘k’, ‘s’, ‘\0’}; char string[20] = “cstutorial”; char string [] = “cstutorial”;

Difference between above declarations are:

when we declare char as “string[20]”, 20 bytes of memory space is allocated for holding the string value. When we declare char as “string[]”, memory space will be allocated as per the requirement during execution of the program.

Whitespace in C

A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it. Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement: int age;

there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. On the other hand, in the following statement: fruit = apples + oranges;
// get the total fruit no whitespace characters are necessary between fruit and = , or between = and apples, although you are free to include some if you wish to increase readability.




Reply by Team

Ask your doubt our team reply fast your question.