0% found this document useful (0 votes)
54 views

Name: Heer Patel Standard: 10 - D Roll No.: 41

The document provides information about C language concepts like its history, structure of a C program, variables, constants, and keywords. It was created by Dennis Ritchie at Bell Labs in 1972 and standardized in 1989. C is a structured language that breaks programs into functions. It has predefined keywords, variables to store data, and constants to represent fixed values.

Uploaded by

Heer Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Name: Heer Patel Standard: 10 - D Roll No.: 41

The document provides information about C language concepts like its history, structure of a C program, variables, constants, and keywords. It was created by Dennis Ritchie at Bell Labs in 1972 and standardized in 1989. C is a structured language that breaks programs into functions. It has predefined keywords, variables to store data, and constants to represent fixed values.

Uploaded by

Heer Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

 Name : Heer Patel

 Standard : 10th – D

 Roll no. : 41
 History of C
 What is C?
 Structure of C Program
› Documentation Section
› Symbolic Constant Definition
› File include Section
› Global Variable Declaration Section
› Main Function
 C Character Set
 C Keywords
 Variables
 Constants
The origin of C has been dated
back to 1972 in Bell Laboratories.
The man who owns the credit of
creating C language is Dennis M.
Ritchie.
It was derived from Basic
Combined Programming
Language commonly known as
BCPL.
Although born in 1972, it was
standardized in 1989 by American
National Standards Institute (ANSI).
From there on, it came to be
known as ANSI C.

Dennis M. Ritchie.
Courtesy : www.japanprize.jp
 C is a structured
language.
 It allows our program
to be broken into
small pieces known
as Functions.
 Set of such functions
then become a C
program.
Documentation
Symbolic Constant Definition Optional
File include Section Section
Global Variable Declaration

main()
{ Compulsory
Declaration Section for all
executable C
Executable Statements programs
}
Function 1
Function 2 User Defined
Functions
Function N
 This section is an optional section. As the name indicates, it is
used for the purpose of documentation.
 It is enclosed within /* and */.
 Whenever the text is enclosed within /* and */, it is considered
as a comment in C. Comments are not processed by C
compiler and are left as it is.
 This section is normally used to tell about purpose of program,
author, date of creation, etc.
 Comments in C program can be added anywhere.
 It is always a good practice to use comments within the
functions as it improves the readability and understanding of
the program.
 To use a symbolic constant in our program, we need to use
#define as a prefix to it.
 Here, #define is known as a pre-processor directive.
 It instructs the compiler to replace all occurrences of
symbolic constants with the values specified against it.
 Normally, symbolic constants are defined using capital letters.
 Doing this differentiates them from normal variables.
 C provides inbuilt or library functions. Some examples are
pow(), sqrt(), etc.
 These functions have a pre-defined purpose, like pow() is
used for calculating value of x raised to given power, sqrt() is
used to find square root of a given number. We can use
these functions in our program if needed.
 To use them, we have to include files that hold information
about these functions.
 These files are known as header files in C. The extension of a
header file is “.h”.
 We use the syntax #include <filename.h> to include header
files in our C program.
 C variables are governed by scope. A scope of C variable is
decided by using opening and closing curly braces { }.
 The variables defined within curly braces are known as local
variables.
 These variables cannot be used outside the scope.
 At times, we need to use a variable in all the functions, such a
variable is known as a global variable.
 This variable is defined before defining all the functions.
 All C programs contain one function with the name main().
 This is the function from where the execution of any C
program starts.
 The control is first transferred to this function and from here
rest of the operations are carried out.
 C language also has Letters Digits White
its own character Spaces
set. A to Z Blank
a to z 0 to 9 Space
 The characters here
Form
are divided into four Feed
categories. Horizontal
1. Letter Tab

2. Digits New
Line
3. White spaces
4. Special Characters Vertical
Tab
 C has some auto double int struct
predefined words.
 ANSI C supports break else long switch
32 predefined
case enum register typedef
words.
 These predefined char extern return union
words in C
language are const float short unsigned
known as
keywords. continue for signed void
 Each keyword has default goto sizeof volatile
a predefined
meaning do if static while
associated to it.
 C program generally accepts input, this input comes in form
of data. To store and manipulate data, we use memory
space.
 The data within this memory space can vary based on the
operations performed on it. The data within memory space is
referred by a name known as variable name.
 The data as it is capable of changing itself is called a
variable.
 To define a variable, we need to adhere to
certain rules. These rules have been
mentioned below:
› Variable name cannot be same as keyword.
› Variable name consists of letter, digit and
underscore. No other special character is
allowed.
› The first character of a variable name must be a
letter or underscore.
› The maximum length of a variable name as per
ANSI standards is 31 characters. However, it is
dependent on compiler.
› The variable names are case-sensitive. Hence,
num, nuM, nUM, nUm, and Num are considered
as different variables.
 The entities of C that do not change its
value throughout the execution of
program are known as constants.
 There are two types of constants in C:
› Numeric Constant
› Character Constant
 The constant that store numeric value is
known as numeric constant.
 They are divided into two categories:
› Integer Constants
› Real Constants
 Integer constant refers to whole numbers. We have three
types of integer constants:
› Decimal
› Hexadecimal
› Octal
 The decimal constants use numeric digits from 0 to 9. We can
use prefix unary plus or minus with such numbers.
 The hexadecimal constants use numeric digits from 0 to 9
and letter A to F. Here A to F refers to numeric values 10 to 15
respectively. The hexadecimal numbers have base 16. When
using this value in C we differentiate it from decimal numbers
by using 0x or 0X as prefix.
 The octal constants use numeric digits from 0 to 7. The base of
number system is 8. When using this value in C, we
differentiate it from decimal numbers by using 0 as prefix.
 Real constant refer to decimal numbers that have fractional
part. Examples are 10.50, -65.75, etc.
 Real constant can also be represented by using scientific
form. In this form a number is represented using a mantissa
and exponent.
 For example, the value 25.75 can be expressed as 0.2575 e 2
or 0.2575 E 2. Here 0.2575 is known as mantissa and 2 is known
as exponent.
 Character constants contains
characters.
 There are two types of character
constants in C:
› Single Character Constant
› String Constant
 A single character constant is represented by using single
character enclosed within single quotes.
 Some examples are ‘H’, ‘v’, ‘7’, ‘$’ etc.
 Here each character constant is associated with a numeric
value known as ASCII (American Standard Code for
Information Interchange).
 String constants are denoted by using sequence of
characters enclosed within double quotes.
 Some examples are “C Language”, “Bye”, “V”.
 String constants don’t have any ASCII value associated with
it.
 Here string constant “V” is not equal to single character
constant ‘V’.
 Here “V” will be allocated two memory spaces while
character ‘V’ will be allocated only one memory space.
 This is due to the fact that strings in C are ended by adding
‘\0’, a null character.

You might also like