KEMBAR78
History of C Programming Language: Dennis Ritchie | PDF | Variable (Computer Science) | C (Programming Language)
0% found this document useful (0 votes)
105 views13 pages

History of C Programming Language: Dennis Ritchie

The document provides an overview of the C programming language, including its history, structure, data types, variables, constants, and errors. It details that C was created at Bell Labs in 1972 to develop the UNIX operating system and has since become widely used. The general structure of a C program includes comments, preprocessor directives, functions, and main(). It also describes different data types, variables, constants, and common errors in C programs.

Uploaded by

ABDUL HAKEEM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views13 pages

History of C Programming Language: Dennis Ritchie

The document provides an overview of the C programming language, including its history, structure, data types, variables, constants, and errors. It details that C was created at Bell Labs in 1972 to develop the UNIX operating system and has since become widely used. The general structure of a C program includes comments, preprocessor directives, functions, and main(). It also describes different data types, variables, constants, and common errors in C programs.

Uploaded by

ABDUL HAKEEM
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

INTRODUCTION

History of C Programming Language

1. C is a programming language which born at “AT & T’s Bell Laboratory” of USA in

1972.
2. C was written by Dennis Ritchie, thats why he is also called as father of c programming

language.

3. C language was created for a specific purpose i.e designing the UNIX operating system

(which is currently base of many UNIX based OS).

4. From the beginning, C was intended to be useful to allow busy programmers to get things

done because C is such a powerful, dominant and supple language

5. Its use quickly spread beyond Bell Labs in the late 70’s because of its

Features of C Programming Language :


1. Middle Level Programming Language
2. Structured Programming Language
3. Modularity
4. Portability
5. Powerful Data Structure
6. The ability to Operate “close to the Machine”

Structure of C Programming Language :


What is program?
Program is nothing but collection of one or more functions it is called program.

What is Function?
Function is nothing but collection statements and performs some specific task.

The General Structure of C programming


#####################################################################

# Comments #

# Preprocessor directives #

# Global Variables #

# int main() #

# { #

# Local Variables; #

# Statements; #

# --------------- #

# ---------------

func1(); #

# return 0; #

# } #

# func1( ) #

# { #

# local variables; #

# statements; #

# -----------

func2(); #

# } #

# func2( ) #

# { #

# local variables; #

# statements; #
# ------------- #

# } #

Compilation and Execution of C Programming Language :


Source Code:
The Program, which has to be executed, is first written into a file it is called source
file and the content of it is called source code, Every File should have .c as its
extension

Pre-Processor:
i. Includes the header files
ii. Remove the Comments
iii. Replace Macros or Expanding the Macros

Compiler:

Compiler is nothing but Converting High level language into low level language

Assembler:

Covering into Assembly language into Object code

Linker:

Linking the Lib + o.s related info to object code and makes executable file

Types of Errors in C Programming Language :


Errors are divided into two types.

1. Compile Time Errors

2. Run Time Errors

1. Compile time Errors in C Programming Language:

i. Compile time Pre-processor error

Ex:#include<stdi.h>

Here “stdi.h” is the fatal error

ii. Compile time Translate errors (Syntatical errors)

Ex:printf(“Helloe\n”)
Here we missed “;” ,so error will come

iii.Linker Errors

Ex:print(“Hello\n”);

2. Run time Errors in C Programming Language:

i.Segmentation Fault: Segmentation is nothing but un authorized memory


access

ii.Bus error: Memory is not at all existed but programmer trying to access that

Data types in C Programming Language:

C data types divided in to two types. They are

1. Primitive or Predefined Data types


2. Non-Primitive or User defined Data Types

Primitive or Pre defined data types in C Programming Language:

char – A single byte , capable of holding one character

int - depend on the host name

float – single precision floating point

double – double precision floating point


Non-Primitive or User defined data types in C Programming Language:

They Are

1. arrays

2. pointers

3. enumerator

4.Structures

5.unions

Keywords in C Programming Language:

1. Keywords are those words whose meaning is already defined by Compiler

2. Cannot be used as Variable Name

3. There are 32 Keywords in C

4. C Keywords are also called as Reserved words


Identifiers in C Programming Language:

C Identifiers

Identifier refers to name given to entities such as variables, functions, structures


etc.

Identifier must be unique. They are created to give unique name to a entity to
identify it during the execution of the program. For example:

int num;

double accountBalance;

Here, num and accountBalance are identifiers.

Also remember, identifier names must be different from keywords. You cannot
use int as an identifier because int is a keyword.

Rules for writing an identifier

1. A valid identifier can have letters (both uppercase and lowercase letters),
digits and underscores.
2. The first letter of an identifier should be either a letter or an underscore.
However, it is discouraged to start an identifier name with an underscore.
3. There is no rule on length of an identifier. However, the first 31 characters
of identifiers are discriminated by the compiler.

Variables

In programming, a variable is a container (storage area) to hold data.

To indicate the storage area, each variable should be given a unique name
(identifier). Variable names are just the symbolic representation of a memory
location. For example:
int playerScore = 95;

Here, playerScore is a variable of integer type. The variable is assigned value: 95.

The value of a variable can be changed, hence the name 'variable'.

In C programming, you have to declare a variable before you can use it.

Rules for naming a variable in C

1. A variable name can have letters (both uppercase and lowercase letters),
digits and underscore only.
2. The first letter of a variable should be either a letter or an underscore.
However, it is discouraged to start variable name with an underscore. It is
because variable name that starts with an underscore can conflict with
system name and may cause error.
3. There is no rule on how long a variable can be. However, only the first 31
characters of a variable are checked by the compiler. So, the first 31 letters
of two variables in a program should be different.

C is a strongly typed language. What this means it that, the type of a variable
cannot be changed.

Constants/Literals

A constant is a value or an identifier whose value cannot be altered in a program.


For example: 1, 2.5, "C programming is easy", etc.

As mentioned, an identifier also can be defined as a constant.

const double PI = 3.14

Here, PI is a constant. Basically what it means is that, PI and 3.14 is same for this


program.

Below are the different types of constants you can use in C.


1. Integer constants

An integer constant is a numeric constant (associated with number) without any


fractional or exponential part. There are three types of integer constants in C
programming:

 decimal constant(base 10)


 octal constant(base 8)
 hexadecimal constant(base 16)

For example:

Decimal constants: 0, -9, 22 etc

Octal constants: 021, 077, 033 etc

Hexadecimal constants: 0x7f, 0x2a, 0x521 etc

In C programming, octal constant starts with a 0 and hexadecimal constant starts


with a 0x.

2. Floating-point constants

A floating point constant is a numeric constant that has either a fractional form or
an exponent form. For example:

-2.0

0.0000234

-0.22E-5

Note: E-5 = 10-5
3. Character constants

A character constant is a constant which uses single quotation around characters.


For example: 'a', 'l', 'm', 'F'

4. Escape Sequences

Sometimes, it is necessary to use characters which cannot be typed or has special


meaning in C programming. For example: newline(enter), tab, question mark etc.
In order to use these characters, escape sequence is used.

For example: \n is used for newline. The backslash ( \ ) causes "escape" from the
normal way the characters are interpreted by the compiler.

Escape Sequences

Escape
Character
Sequences

\b Backspace

\f Form feed

\n Newline

\r Return

\t Horizontal tab

\v Vertical tab

\\ Backslash
Escape Sequences

Escape
Character
Sequences

\' Single quotation mark

\" Double quotation mark

\? Question mark

\0 Null character

5. String constants

String constants are the constants which are enclosed in a pair of double-quote
marks. For example:

"good" //string constant

"" //null string constant

" " //string constant of six white space

"x" //string constant having single character.

"Earth is round\n" //prints string with newline

6. Enumeration constants

Keyword enum is used to define enumeration types. For example:


enum color {yellow, green, black, white};

Here, color is a variable and yellow, green, black and white are the enumeration


constants having value 0, 1, 2 and 3 respectively.

You might also like