Learn C Programming Language | LearntHub

Introduction Of C Programming LANGUAGE:- 

C is very popular programming language. It is a structured programming language. It is also a machine independent programming language. C has been used to write everything from operating systems to complex programs like the Python interpreter, Oracle database etc.


The C language is developed by Dennis Ritchie at AT&T Bell Laboratories, in 1972 It was named C because many of its features were received from an earlier language B. 
C programming

In 1970, the Ken Thompson B language since it was a simple version of the BCPL (Basic Combined Programming Language) BCPL was developed by Martin Richards, in 1967.
C is the programming language most frequently associated with UNIX. Since the 1970s, the bulk of the UNIX operating system and its applications have been written in C. Because the C language does not directly rely on any specific hardware architecture, UNIX was one of the first portable operating systems.

Read Also:
  1. First C Program
  2. FlowChart
  3. Operators
In other words, the majority of the code that makes up UNIX does not know and does not care which computer it is actually running on. Machine-specific features are isolated in a few modules within the UNIX kernel, which makes it easy for you to modify them when you are porting to a different hardware architecture.
In 1983, the American National Standards Institute (ANSI) established a committee to 
standardize the definition of C. The resulting standard is known as ANSI C, and it is the 
recognized standard for the language, grammar, and a core set of libraries. The syntax is slightly 
different from the original C language, which is frequently called K&R for Kernighan and Ritchie. 
There is also an ISO (International Standards Organization) standard that is very similar to the ANSI standard.
It appears that there will be yet another ANSI C standard officially dated 1999 or in the early 
2000 years; it is currently known as "C9X."

Basic Structure:- 

The program written in C language follows this basic structure. The sequence of sections should be as they are in the basic structure. A C program should have one or more sections but the sequence of sections is to be followed.:
1. Documentation section
2. Linking section
3. Definition section
4. Global declaration section
5. Main function section
    Declaration section
    Executable section
6. Sub program or function section

1. Documentation Section:- 

It comes first and is used to document the use of logic or reasons 
in your program. It can be used to write the program's objective, developer and logic details. 
The documentation is done in C language with /* and */ . Whatever is written between 
these two are called comments.

2. Linking Section:- 

This section tells the compiler to link the certain occurrences of keywords or functions in your program to the header files specified in this section.
Exa: #include <stdio.h>

3. Definition Section:- 

It is used to declare some constants and assign them some value.
Exa: #define MAX 25
Here #define is a compiler directive which tells the compiler whenever MAX is found in 
the program replace it with 25.

4. Global Declaration Section:- 

Here the variables which are used through out the 
program (including main and other functions) are declared so as to make them global(i.e 
accessible to all parts of program)
Exa: int i,j,k; (before main())

5. Main Function Section:- 

It tells the compiler where to start the execution from 
point from execution starts 
main function has two sections

6. declaration section:- 

In this section the variables and their data types are declared.

7. Executable section:- 

This has the part of program which actually performs the task we 

8. Sub Program Section:-

This has all the sub programs or the functions which our program needs.
Ex- This is a simple program of c language.

Character Set:-

C language uses the uppercase letters A to Z.
Ex- A B C D........Z
The lowercase letters a to z.
Ex- a b c d......z
The digits 0 to 9.
Ex- 0 1 2 3.....9
Certain special characters as building blocks to form a basic C program elements such as constants, variables, operators, expressions etc.
 Ex- @,%,&,?,=,+,-,/,;,:,",


In a passage text individual words and punctuation marks are called tokens . Similarly in a program the smallest  individual units are known as C tokens .C programs are written using these tokens and the syntax of the language.
There is six type of tokens:
C tokens

1. Identifiers:- 

Names of the variables and other program elements such as functions, array,etc,are known as identifiers.
There are few rules that govern the way variable are named(identifiers).
1. Identifiers can be named from the combination of A-Z, a-z, 0-9, _(Underscore).
2. The first alphabet of the identifier should be either an alphabet or an underscore. 
digit are not allowed.
3. It should not be a keyword.
Eg: name,ptr,sum
In other word, Identifiers are the names you give to variables, constants and functions etc.  There are some rules for giving these names that you follow.
If you do not follow these rules, then there is an error in the program.
These rules are being explained further:
1. @,%, - characters are not allowed in identifiers.
2. C is case sensitive language.Hence age and age 2 are different identifiers.
3. You cannot use operators in identifiers.
4. You can start the identifier with either character or underscore.The identifier cannot be initialized from digits.

2. Keywords:-

There are certain words, called keywords  that have a 
predefined meaning in C language. These keywords are only to be used for their intended purpose and not as identifiers.
Similarly, The words already defined in C Compiler are called Keywords. This means that when designing a C language, some words are reserved for performing specific tasks. Such words are called keyword or reserved words. All C compilers support 32 keywords.

3. Constants:-

A quantity that does not vary during the execution of a program is known as a constant supports two types of constants namely Numeric constants and character constants.

1. Numeric Constant:- 

1. Example for an integer constant is 786,-127
2. Long constant is written with a terminal ‘l’or ‘L’,for example 1234567899L is a Long
3. Unsigned constants are written with a terminal ‘u’ or ‘U’,and the suffix ‘ul’ and ‘UL’ indicates unsigned long. for example 123456789u is a Unsigned constant and 1234567891ul is an unsigned long constant.
4. The advantage of declaring an unsigned constant is to increase the range of storage.
5. Floating point constants contain a decimal point or an exponent or both. For Exa:
 123.4,1e-2,1.4E-4,etc.The suffixes f or F indicate a float constant while the absence of f or F indicate the double, l or L indicate long double.

2. Characters Constants:-

A character constant is written as one character with in single quotes such as ‘a’. The value of a character constant is the numerical value of the character in the machines character
set. certain character constants can be represented by escape sequences like ‘\n’. These sequences look like two characters but represent only one.

4. Variables:-

A quantity that can vary during the execution of a program is known as a variable. 
To identify a quantity we name the variable for example if we are calculating a sum of two numbers we will name the variable that will hold the value of sum of two numbers as 'sum'.

5. Data Types:-

To represent different types of data in C program we need different data types. A data type is essential to identify the storage representation and the type of operations that can be p
erformed on that data. C supports four different classes of data types namely 
1. Basic Data types
2. Derives data types
3. User defined data types
4. Pointer data types

6. Operators:-

An operator is a symbol that tells the compiler to perform certain mathematical or logical manipulations. They form expressions.
C operators can be classified as:
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment or Decrement operators
6. Conditional operator
7. Bit wise oprators
8. Special oprators

Post a comment