Chapter 4- Programming in C----> Introduction

Introduction

C programming is one of the popular and powerful high level language developed by Denish Ritchie. It was originally developed for development of UNIX operating system. Later its uses expands to application development as well as system program development. So, it is also known as middle level language. In brief,

 

Some of the implementation of C language are:

·         It is used to develop Operating System eg. UNIX.

·         It is used to develop new programming platform such as C++, C# [C++ is used in Blockchain Technology (Bitcoin, Etherium etc), also C++ is used in various game engine (Unreal engine and many more)]

·         It is used to develop popular web browser such as Mozilla Firefox, Thunderbird etc.

·         It is used in development of various GUIs (Graphical User Interface) and IDEs (Integrated Development Environments).

·         Popular Database Management System (DBMS) like MYSQL was developed by using C.

 

Some of the features of C language are:

·         It is a structural programming language. (i.e. it support various control structure like sequence, branching, looping)

·         It is a modular programming language. (i.e. big program can be reduced into simpler small program blocks called module)

·         It supports graphics.

·         It has huge library function.

·         It is case-sensitive language.

 

 

Data type:C support both numeric as well as alphanumeric datas. Frequently used Data types in C are:

Type

Data type used

Format Specifier

Numeric

int (for non-decimal numbers)

%d

Numeric

float (for decimal numbers)

%f

Alphanumeric

char (for string)

%s or %c

[Note: There are more data type which we will discuss later in need]

 

Variable:

Those entities which holds either numeric or alphanumeric values in program and may change its value through out the time of program execution are known as variables.

 

Rule for writing variable:

·         Variable name should not start will number. Eg, 1age is invalid, age1 is valid

·         Variable name should not have blank space. Eg, first name is invalid, firstname is valid

·         Keywords cannot be used as variable name. Eg, printf = 2; is invalid, num = 2; is valid

·         Uppercase variable name are different from lowercase variable name. Eg, age = 2 is different from AGE = 2

[Note: try to use relevant word as variable name without using any special symbol]

 

Operators: 

The special symbol or sign used to perform some specific function or operation are called operators.

 

Types of operators:

 

a) Arithmetic operator

+ , - , * , / , %

Note that Here,  if c = 5/2

The result will be 2 if we initialize ‘c’ as int c.

The result will be 2.5 if we initialize ‘c’ as float c.

If c = 5%2 then result will be 1. Since, % gives remainder after division.

 

b) Relational operator

> , < , >= , <= , != (not equal to) , == (equal to)

[Note: Here in C language if you want to compare the equal to is referred by == (two equals)]

 

c) Assignment operator

= is an assignment operator.

[Note If a = 2 then it mean 2 is assigned to variable a, it does not mean a also has value 2 and both are equal.]

 

d) Logical operator

For logical AND use &&

For logical OR use ||

For logical NOT use !

 

Header files in C

It is a file in C library with .h extension and contains several functions declaration and definition. Such as we use.

 

#include for standard input output function eg, printf, scanf etc

#include for mathematical function eg, pow, sin, cos etc

#include for graphical element eg, circle, rectangle, line etc

#include for string handling function eg, strcpy(), strlen(),strupr() etc

And more. [header file can be added according to requirements]



 


 

 

 




 


 


Popular posts from this blog

Computer