Introduction to C

     PST-PDF                                 Instagram                              Twitter                        YouTube

{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}

--------------------------------------------------------------------------------------------------------------------

1. INTRODUCTION

-------------------------------------------------------------------------------------------------------------------
1.1 Introduction
    C language is one of the most popular computer languages today because it is a structured, high             level, machine independent language. It allows software developers to develop programs without         worrying about the hardware platforms where they will be implemented. C is called a high level,             compiler language. The aim of any high level computer language is to provide an easy and natural         way of giving a program of instructions to a computer.

            C is a remarkable language. Designed originally by Dennis Ritchie, working at AT&T Bell                     Laboratories in New Jersey, it has increased in use until now it may well be one of the most                     widely-written computer languages in the world. C is a structured language. It allows variety of              programs in small modules. It is easy for debugging, testing, and maintenance if a language is a             structured one.

✔C language is helpful to develop low level application that interacts with system hardware such as device drivers, firmware’s, operating system etc and high level applications (user level). C language programs are portable; you can easily run on different PC.
✔C language supports modular programming style, by using this style you can divide your program (problem) into small pieces and integrating them, you can build a complete program.
✔C language has only 32 keywords, so it is very easy to learn, understand and use.
✔C language follows top to down programming approach.

For Programming Training:
DM me Instagram
---------------------------------------------------------
---------------------------------------------------------
1.2 History
CPL stands for Common Programming Language. Developed by Martin Richard in the University of Cambridge in the early 1960s. BCPL stands for Basic Combined Programming Language. Extension of CPL. Developed by Martin Richard in the University of Cambridge in 1969.

It allows the direct access of memory. B language was developed by Ken Thompson and Dennis Ritchie in 1969. C language was developed by Dennis Ritchie in 1972 at Bell Laboratories in the USA. The main aim of Dennis Ritchie to create C language is to develop a programming language to create a UNIX operating system.

ANSI
C ANSI stands for American National Standard Institute.

After 1972, different companies created their own version of C language so then there was a need to standardize the frame of C language, for this reason, ANSI creates a committee in 1988, the C is the standardize and the name was given to it is ANSI C ( C 89).

Reasons behind popularity of C
✔Simple, reliable and easy to use.
✔Portability of compiled code.
✔Standard library concept ( system defined function, library function).
✔Ready to access the hardware whenever it is required.
✔Basic of every programming language like C++ or Java.
✔Speed is very fast.
✔Generally, every OS is written in C language and if we want to extend the features of OS, then we need some device drivers and those devices drivers are also written in C language.
✔Rich in operators. A total number of operators = 45, Total number of Keywords = 32.

Characteristics of C
✔General Purpose Programming Language.
✔Structured Programming Language.
✔Rich in operators and data types.
✔Less number of keywords or reserved keywords.
✔Pointer arithmetic and manipulation.
✔The user can add their own defined function into the system library.
✔Compact representation of expression (combination of variables and constant).

For Programming Training:
DM me Instagram
---------------------------------------------------------
----------------------------------------------------------
1.3 Compilers and IDE
What is IDE? 
IDE is nothing but Integrated Development Environment. IDE is a tool that provides user interface with compilers to create, compile and execute C programs.

Example: 
Turbo C, DevC++,etc. These provide Integrated Development Environment with compiler for both C and C++ programming language.

✔ Eclipse
✔ Code::Blocks
✔ GNAT Programming Studio
✔ Visual Studio Code
✔ CodeLite
✔ NetBeans 8
✔ Qt Creator
✔ Sublime Text
✔ Dev C++
✔ C++ Builder


For Programming Training:
DM me Instagram
---------------------------------------------------------
---------------------------------------------------------
1.4 Keywords

✔ Keywords are preserved words that have special meaning in C language.
✔ The meaning of C language keywords has already been described to the C compiler. 
✔ These meaning cannot be changed. 
✔ Thus, keywords cannot be used as variable names because that would try to change the existing meaning of the keyword, which is not allowed.
✔ (Don't worry if you do not know what variables are, you will soon understand.) There are total 32 keywords in C language.

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


For Programming Training:
DM me Instagram
---------------------------------------------------------
---------------------------------------------------------
1.5 Identifiers

In C language Identifiers are the names given to variables, constants, functions and user-define data. These identifier are defined against a set of rules.

Rules
✔ An Identifier can only have alphanumeric characters(a-z , A-Z , 0-9) and underscore(_).
✔ The first character of an identifier can only contain alphabet(a-z , A-Z) or underscore (_).
✔ Identifiers are also case sensitive in C.
✔ For example name and Name are two different identifiers in C.
✔ Keywords are not allowed to be used as Identifiers.
✔ No special characters, such as semicolon, period, whitespaces, slash or comma are permitted to be used in or as Identifier.

When we declare a variable or any function in C language program, to use it we must provide a name to it, which identified it throughout the program, for example:

int age = 20;
Here age is the name or identifier for the variable which stores the value 20 in it.

Character Set
In C language characters are grouped into the following catagories,
✔ Letters(all alphabets a to z & A to Z).
✔ Digits (all digits 0 to 9).
✔ Special characters, ( such as colon :, semicolon ;, period ., underscore _, ampersand & etc).
✔ White spaces.


For Programming Training:
DM me Instagram
-------------------------------------------------------------------
-------------------------------------------------------------------
1.6 Variables

When we want to store any information(data) on our computer/laptop, we store it in the computers memory space. Instead of remembering the complex address of that memory space where we have stored our data, our operating system provides us with an option to create folders, name them, so that it becomes easier for us to find it and access it.

Similarly, in C language, when we want to use some data value in our program, we can store it in a memory space and name the memory space so that it becomes easier to access it.

The naming of an address is known as variable. Variable is the name of memory location. Unlike constant, variables are changeable, we can change value of a variable during execution of a program. A programmer can choose a meaningful variable name.

Example: 
average, height, age, total etc.

Rules:
✔ Variable names in Visual C++ can range from 1 to 255 characters. To make variable names portable to other environments stay within a 1 to 31 character range.
✔ All variable names must begin with a letter of the alphabet or an underscore( _ ). 
✔ After the first initial letter, variable names can also contain letters and numbers.
✔ No spaces or special characters, however, are allowed.
✔ Uppercase characters are distinct from lowercase characters.
✔ Using all uppercase letters is used primarily to identify constant variables.
✔ You cannot use a C++ keyword (reserved word) as a variable name.


For Programming Training:
DM me Instagram
-------------------------------------------------------------
-------------------------------------------------------------
1.7 Datatypes
Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that we can use in our program. These datatypes have different storage capacities.

C language supports 2 different type of data types:

Primary data types:
These are fundamental data types in C namely integer(int), floating point(float), character(char) and void.

Derived data types:
Derived data types are nothing but primary datatypes but a little twisted or grouped together like array, structure, union and pointer. 

✔ Data type determines the type of data a variable will hold.
✔ If a variable x is declared as int.
✔ It means x can hold only integer values.
✔ Every variable which is used in the program must be declared as what data-type it is.
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BCA                                        PST & Programming C                                   Allrounder Sita Ram Sahu
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
>

No comments:

Post a Comment