Describe about C Programming?
What is the Characteristics of C Language?
What is Constant? Explain types of Constant.
What is variable ? Types of Variable.
What is Identifier?
What is Keyword in C?
What is Tokens in C?
1. PAPER: INTRODUCTION PROGRAMMING LANGUAGE USING C
PAPER ID: 20105
PAPER CODE: BCA 105
DR. VARUN TIWARI
(ASSOCIATE PROFESSOR)
(DEPARTMENT OF COMPUTER SCIENCE)
BOSCO TECHNICAL TRAINING SOCIETY,
DON BOSCO TECHNICAL SCHOOL, OKHLA ROAD , NEW DELHI
3. OBJECTIVES
In this unit you will learn:
1. To understand about C Language.
2. To learn about the Characteristics of C
3. To use of C Language.
4. To understand about the Character sets in C
5. To understand to Installation of C in PC
6. To write simple computer program in C
7. To use input and output statements in C
8. To learn about the identifier and keyword in C
9. To learn about the Constants in C
10. To understand about the array and variables.
11. To learn about the declaration of identifier , keyword , constant , data types and variables in C
4. INTRODUCTION ABOUT C LANGUAGE
1. In 1970 Dennis Ritchie created a new language called C. It is superseded of old
programming language was called B.
2. It is developed at AT & T’s Bell Laboratories of USA in 1972.
3. C is powerful procedural based language.
4. It is very simple , reliable and easy to use.
5. Basically c was designed for the operating system.
6. It is supporting structural programming.
7. Unix system development started in 1969 and it’s code re-written in C language in c in 1972.
8. Oracle database development started in 1977 and it’s code was re-written in C language
in 1983.
9. In 1985 window 1.0 was released and it’s kernel was re-written in C Language.
5. INTRODUCTION ABOUT C LANGUAGE
10. Linux Kernel started in 1991 and was written in C Language.
11. It is Middle level language. There are three types of language (a) Low Level
Language Ex: Machine code and Assembly Language (b) Middle Level Language
Ex: c and c++ (c) High Level Language Ex: Java , Cobol , Pascal , Fortran and Python
etc.
12. In 1980, Bjarne Stroustrup started working on a new language, called "C with
Classes”. This language included some unique features of the C language, hence it
was known as C ++.
13. American National Standards Institute established a committee in 1983. The goal of
this committee was to produce “an unambiguous and machine-independent
definition of the language C‘’. The result is the ANSI standard for C.
6. CHARACTERISTICS OF C LANGUAGE
• Simple.
• Robust and Reliable Language.
• It is easily install and transportable.
• It is easy to use.
• C language package/exe file is very small in Size.
• It is Structural Language.
• It is use of Pointer for allocating a memory , pointer to array , structure etc.
• Recursion.
• It is Machine Independent.
• It is Middle Level Language.
7. USE OF C LANGUAGE
• To design a Database System
• To design Graphics Packages (GUI Platform)
• To design a Word Processor
• To design a Spreadsheet
• To design Embedded devices code ex. Microwave Oven , Washing Machine
and Digital Camera etc.
• To design a device driver code.
• To design gaming framework code in c
• Operating System Development
• Compiler and Assembler Development
8. CHARACTER SET IN C LANGUAGE
A character set denotes any Alphabets, digits , Special Characters , White
space characters and escape sequence characters used to represent
information. Tables shows the valid alphabets , digits , special , white space
characters and escape sequence characters. There are two categories
available in C for Character set.
1. Basis Character Set:
a. Alphabets
b. Digits
c. Special Characters
d. White Space
9. CHARACTER SET IN C LANGUAGE
2. Task Performance Character Set
a. Escape Sequence
1. Basis Character Set:
a. Alphabets
a. Upper Case : A to Z
b. Lower Case : a to z
b. Digits
a. 0,1,2,3,4,5,6,7,8,9
10. CHARACTER SET IN C LANGUAGE
c. Special Characters:
Special
Character
Meaning Special
Character
Meaning
~ Tilde ( Left Parenthesis
+ Plus Sign ) Right Parenthesis
% Percent Sign ‘ Apostrophe
< Less Than ; Semicolon
| Vertical Bar : Colon
@ At Symbol [ Left Bracket
_ Under Score ] Right Bracket
# Number Sign (Hash
Symbol)
“ Quotation Marks
- Minus Sign ! Exclamation Mark
= Equal To , Comma
> Greater Than . Dot Operator
^ Caret { Left Flower Brace
& Ampersand } Right Flower Brace
* Asterisk ? Question Mark
$ Dollar Sign
/ Slash
11. CHARACTER SET IN C LANGUAGE
d. White Space Characters:
White Space
Character
Meaning White Space
Character
Meaning
b Blank Space Back Space
v Vertical Tab ” Double Quote
f Form Feed 0 Null
t Horizontal Tab ’ Single Quote
r Carriage Return ? Question Mark
n New Line a Alarm (bell)
12. CHARACTER SET IN C LANGUAGE
2. Task Performance Character Set
a. Escape Sequence (Backslash Characters)
Character Sequence Ascii
Value
Escape Sequence Result
Null 0 0 Null
Alarm (bell) 7 a Beep Sound
Back space 8 b Moves previous position
Horizontal tab 9 t Moves next horizontal tab
New line 10 n Moves next Line
Vertical tab 11 v Moves next vertical tab
Form feed page 12 f Moves initial position of next
Carriage return 13 r Moves beginning of the line
Double quote 34 " Present Double quotes
Single quote 39 ' Present Apostrophe
Question mark 63 ? Present Question Mark
Back slash 92 Present back slash
Octal number 0
Hexadecimal number x
15. INSTALLATION OF C LANGUAGE IN PC
1. Download this Software from
https://drive.google.com/drive/u/1/folders/1CXc3_YT1StfM-yQ6qiR7UhkgFOhJKssw
2. After Downloading this software then Extract this Software via some Zip Software or Window 10 Extractor.
3. After that select Setup file and press double click and install this software on your PC.
4. After completing installation of Software then follow next slide for making a new program in turbo c.
5. If you want to create a new program then select a file menu select New and click.
6. After writing a new program then save this program by using F2 key.( for saving purpose).
7. After saving this program , compile this program by using Alt + F9 key.
8. After compiling process now execute this program by using ctrl + F9 Key.
9. In the next slide, I have a complete brief about this program.
16.
17.
18. TOKENS
• There are six types of Tokens: Identifiers , Keywords , Constants , String Literals
,Operators and separators. Blanks, horizontal and vertical tabs, newlines,
form feeds and comments as described below (collectively, ``white space'')
are ignored except as they separate tokens. Some white space is required to
separate otherwise adjacent identifiers, keywords, and constants.
19. IDENTIFIER , KEYWORD , VARIABLES AND CONSTANTS IN C
Identifier: An identifier is used to identify elements of a program. Ex. Name of the
variable , function name , array , structure and union etc. There are some rules
under the identifier like:
1. The first character of an identifier should be either character or underscore ex.
Ab , A , _Abc_ , temp_ etc.
2. The first character should not be a digit Ex. 2abc.
3. Identifier are case sensitive. Ex: A or a both are different.
4. Comma and blank spaces do not fall inside the identifier.
5. Keyword can not use as an identifier.
6. Whitespace character can not use as an identifier.
20. 7. The length of identifier should not be more than 31.
8. Identifier should be a meaningful and easy to use.
Example :
1. Abc , _abcd_ , Abc_bcd , a233rrr , A , a // Valid Identifier
2. 2kkkk , abv bbb, bbbb , ,uuoo , add#r // Not a valid Identifier
21. IDENTIFIER , KEYWORD , VARIABLES AND CONSTANTS IN C
Keyword: Some identifiers are reserved for the use as a keywords and may not be used
otherwise. There are 32 keywords available in c language.
1. Auto: This is Storage Class Specifier in C. This is called automatic.
2. Break : This is used for break in any statement in C.
3. Double: Double is used to declare decimal number in c.
4. Int : Declare numeric variable in C.
5. Struct: It is a user defined data types. It is to represent a single record.
6. Else: It is a statement. It is return as true/false.
7. Long: It is numeric data type. But bigger in size int.
8. Switch: It is a statement. It is used for checking multiple condition.
9. Case: list of value passing in switch. Each value is called a case.
10. Enum: It is user defined data types. It is consist of integral constants.
11. Register: It is storage class specifier.
22. IDENTIFIER , KEYWORD , VARIABLES AND CONSTANTS IN C
12. typedef: this keyword is used to redefine the name of an already existing variable.
13. Char: defined char type variable.
14. Extern: It is storage class specifier. It is used to extend visibility of function or variable.
15. Return: A return statement can return a value to the calling function
16. Union: It allows to store different data types in same memory location.
17. Const: const variable can be initialized once only. The default value of this variable is 0.
18. Float: It is used for decimal number but less than in size float.
19. Short: It is data type same as int.
20. Unsigned: it can only represent non-negative values.
21. Continue: The continue statement skips the current iteration of the loop and continues
with the next iteration.
22. For: It is a loop . It is used to repeat a block of code.
23. Signed: It can represent both positive and negative values.
23. IDENTIFIER , KEYWORD, VARIABLES AND CONSTANTS IN C
24. Void: it indicates that the function does not return a value.
25. Default: The default statement is executed if no case constant-expression value is equal
to the value of expression .
26. Goto: It is called Jump Statement. It is used to jump one statement to other statement.
27. Size of: It is used to find the size of any data types.
28. Volatile: volatile keyword is qualifier that prevents from compiler optimization and tells to
compiler that value can change without any action taken by code.
29. Do: do is used with the help of while condition in C so that is called do while.
30. If : it is used to check one or more condition if condition is true then this statement run.
31. Static: static variable scope is throughout the program.
32 while: While loop is also known as a pre-tested loop.
24. IDENTIFIER , KEYWORD, VARIABLES AND CONSTANTS IN C
Variables: A variable is used to store a value or it can hold only the same type of
constant. There are two types of variables: 1. Internal Variables (Local Variables) 2.
External Variables (Global Variables). There are some rules for declaring a variable
in C.
1. The combination of variable alphabets ,digit or underscore. The length of
variable up to 247 characters.
2. The first character of variable name must be alphabets or underscore (_).
3. Variable are case sensitive. Ex: A or a both are different.
4. No Commas and blank spaces allows in variable declaration.
5. C is a strongly typed language. This means that the variable type cannot be
changed once it is declared. Ex. Int p=10; //ok p =19.8 // error
6. No Special Symbols can be used (rather than _) in a variable names.
25. IDENTIFIER , KEYWORD, VARIABLES AND CONSTANTS IN C
Constants: Constant is an entity does not change where as variable is an entity that
may change. There are two major categories of constant:
1. Primary Constants : Integer , Real , octal & hexadecimal , string , Character.
2. Secondary Constants : Array , Pointer , Structure , union ,Enumeration etc.
Constant Example
Integer constants
int (11, 44,-23.-55)
unsigned int (1233u, 2123U)
long int (333,444) , long long int (888,99,55)
Real or Floating point constants
float (12.44)
doule (556.779)
Octal constant int ( 017) /* start with 0 */
Hexadecimal constant int (0x66) /*start with 0x*/
character constant char ( ‘M’,’N’,’O’)
String Constant Char (“hellllo” , “how”)
26. RULES OF CONSTANT
For Integer constant:
1. An integer constant must have at least one digit.
2. It must not have decimal point.
3. No commas or blank space are allowed.
For Real Constant:
1. An real constant must have at least one digit.
2. It must have a decimal point.
3. It either positive or negative. Default sign is positive.
4. No commas or blanks are allowed.
27. RULES OF CONSTANT
For Character and String constant:
1. A character constant is a single alphabet , a single digit or single special symbol
enclosed with in single inverted commas.
2. A string constant is a multiple alphabet, a multiple digit or multiple special
symbol enclosed with in double quotes.
Symbolic Constant :
It is a special constant that is represent a symbol in our program. Example #define
Ex- #include<conio.h>
#include<stdio.h>
#define op 34.56
28.
29. ARRAY
Array is a collection of Similar data type. It is used to store multiple data in a single variable.
Declaration of array:
#include<conio.h>
#include<stdio.h>
Void main()
{
int a [5]; // this is declaration of array
int p;
for (p=1;p<=10;p++)
{
scanf(“%d”,&a[p]);
}
for (p=1;p<=5;p++)
{
printf(“Output is -: %d”,a[p]);
}
getch();
}
30. DATATYPES IN C
Datatype: Datatype represent a type of data which is store under the variable and used
for the function declaration. It tells the compiler how the programmer plan to use the data. It
provides a set of values from which an expression (i.e. variable, function, etc.) may take its
values. There are different types of data used in c language. Ex:
1. Preemptive Datatype
a. Integer
b. Character
c. Floating
2. Non-Preemptive Datatype
a. Array
b. Function
c. Pointer
d. Structure
e. Enum
f. union
31. Datatypes Description variable Conversion / specifier Range of Datatype
Char Character or string %c (char) , %s (string) -128 to 127
int Integer %d -32768 to 32767
short or short int Short integer %d -32768 to 32767
long
long int
Long integer %d
%ld
-2147483648 to
2147483648
unsigned char Unsigned character %u 0 to 255
unsigned int Unsigned int %u 0 to 65535
unsigned short Unsigned short integer %u 0 to 65535
unsigned long Unsigned long integer %u 0 to 4294967295
float Single – precision floating point Signed floating-point value
in E-notation (%e) , Signed
floating-point value (%f)
+ - 3.4 X 10 -38 to
+ - 3.4 X 10 38
double / long float Double precision floating point %f , %lf + - 1.7 X 10 -308 to
+ - 1.7 X 10 308
Signed decimal integer Signed decimal integer %i
Unsigned octal (base 8)
int
Octal integer %o 2 bytes
Unsigned hexadecimal
(base 16) int
Hexadecimal integer %x 2 bytes
%% printf("Output is %d %%”,8); (percent character)