Getting started with C Language

Introducing C

Brief History

C - the general-purpose programming language was born at “AT & T’s Bell Laboratories” of USA in 1972. Dennis Ritchie designed and implemented the first C compiler. This language was created for a specific purpose: to design the UNIX operating system , thus C has been closely associated with the UNIX operating system for which it was developed - since the system and most of the programs that run it are written in C. In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C.  In 1988, the ANSI adopted a ``new and improved'' version of C, known today as ``ANSI C'' or the ANSI standard. . ANSI C was then approved by the International Standards Organization (ISO) in 1990.


The structured language C is one of the early programming languages but still the best programming language to learn quickly. C was used for developing systems applications like Database Systems, Language Interpreters, Compilers and Assemblers, Operating Systems , Network Drivers and Word Processors. For instance Linux OS ,PHP and  today’s most popular RDBMS MySQL are written in C. Basically it has a collection of C library functions but we can also create our own functions and add to the  C library .

Why  C ?

  • Compact
  • Fast
  • Efficient
  • Powerful  
  • Standard for program development with wide acceptance
  • Portable
  • Flexible
  • Supports modular programming style
  • Useful for all applications
  • C is the native language of UNIX
  • Easy to interface with system devices/assembly routines
  • Ability to extend itself
  • user-defined functions(UDF) makes program more simple and easy to understand
  • The most popular  RBDMS (Relational DataBase Management System) MySQL have been written in C.
  • C has been written in assembly language.

C program structure Introduction


Header files

Every c programs will have a preprocessor directive which is also called header files. Preprocessor directives are actually the instructions to the compiler itself. They are not translated but are operated directly by the compiler. Note that preprocessor statements begin with a #symbol. The most common preprocessor directive is include directive.

Example :


Main function 

C program must have one special function main () from where the execution begins when the program is running. This does not have to be the first statement in the program, but it must exist as the entry point.

We write a main function as :

main is a keyword and parenthesis () denotes it is a function.

Body of the program

Body of a c program is followed by the main function. It is usually enclosed in {}

For instance

     Body of the program

Program statements

They are the statements or lines used to write a proram.

Example :

    Program statement1;
    Program statement2;
    Program statement n;

Semicolon (;)

Every program statements are terminated using a semicolon . Header files and main () functions are NOT terminated by a semicolon. The c compiler scans the statement up to semicolon, or in other words a semicolon denotes the end of a program statement. A  C statement without semi colon creates an error statement.

Here we describe how to write a simple program in C language , to develop systems applications .

int main(){
printf(“hello world\n”);
return 0;


The above  program describes how to print the word “hello world” on the screen.


Basic building blocks


Tokens are individual words and punctuation marks in C. In C, program the smallest individual units are known as C Tokens. C has six types of tokens are there .They are

  • Keywords
  • Identifiers
  • Constants
  • Operators
  • Strings
  • Special characters



It’s a type of tokens which convey a special meaning to the compiler or in other words it have standard predefined meaning in C. C language is formed using syntax and keywords. Syntax is the set of rules and regulations which we followed to write a program. Any instructions that mismatches with C language Syntax generates an error while compiling the program. Even a keyword have its own syntax. They are

  • Keywords are all lowercase we cannot use uppercase letters as keywords.

For instance the keyword printf convey the meaning     that we want to print something on the screen where PRINTF is not.

  • Keywords cannot be used for other purposes as they have intended meaning.
  • It can’t used as programmer defined identifier.
  • It can’t be used for variable names.

Some of the keywords we commonly used in c language are given below :

printf , scanf , int , char , void , if , for , while , do , float etc



The names that given to various program elements are called identifiers. It may be variables, symbolic constants or functions.

Identifiers can be

  • Alphanumeric - combinations of ( A-Z , a-z , 0-9)
  • Underscore ( _ ) can be used along with alphanumeric ,it is          considered as a letter .
  • The first character must be an alphabet.
  • Upper case letters and lower case letters are allowed.
  • Case dependent which means A and a are distinguishable.
  • Keywords are not allowed.

Examples : fuction1, value, pie.



  As the word meaning constants are the tokens which does not change the value during execution of the program.  Broadly constants are divided in to two.

  1. Numeric Constants
  2. Integer Constants
  3. Real Constants
  4. Character Constants
  5. Single Character Constants
  6. String Constants

Integer constants

An integer constant refers to a sequence of digits. Integer constants contains an integer number and it will not change the value during the execution of the program

Examples  : 125    -562    0    9635    +776

Space, commas, and non-digit characters are not permitted between digits.

Examples for don’ts  : 15 750    20,000    $6325

Floating-point constants

  It’s same as integer constant but the value is a float value. Integer and floating point constants are  often referred to as numeric-type constants by the reason

Integer and floating-point constants represent numbers.

Example : 3.14


Character constants

Character constants are the constant which use single quotation around characters.

Example :’a’


String constants

String constants are the constant which use double quotation around a set of  characters.

Example :”welcome”



As in mathematics an operator is a symbol which helps do a certain mathematical or logical manipulations. Operators are used in C language program to operate on data and variables, or it helps the user to command the computer to do such manipulations. In C there are a rich set of operators.

Types of operators

  • Arithmetic operators
  • Relational operators
  • Logical operators
  • Assignment operators
  • Increment and Decrement operators
  • Conditional operators
  • Bitwise operators
  • Special operators.



A string in C is collection of characters enclosed in double quotes, or in other words string is a character array. we need an array of characters to store strings. Thus, in C string is stored in an array of characters. Each character in a string occupies one location in an array. The null character ‘\0’ is put after the last character to denote end of the string. A string may contain any character, including special control characters, such as \n, \t, \\ etc...

Example : “welcome to c language”


Special characters

They are used for special purposes such as to control the cursor movements. Usually they are written into an ordinary string or character by typing a backslash character \ followed by some other character


\n – new line

\t –tab

\b – backspace



This tutorial introduces you to C language. Many tutorials has been written. We are writing this tutorial to be brief and to the point, so that you concentrate on what matter, rather than finding yourself in a mess. We want you to get a start and build form knowledge you will gain from this tutorial


We will cover environment needs as we progress through this tutorial. At the very least you will need a PC with windows or Linus operating system.


Programmers new to C Language

Learning Objectives

Learn basics of C language and build from that knowledge.

Author: Subject Coach
Added on: 3rd Jan 2015

You must be logged in as Student to ask a Question.

None just yet!