SlideShare a Scribd company logo
Vineet Sharma
Introducing of C
• C is a programming language
developed at AT & T Bell Laboratories
of USA in 1972, designed and written
by Dennis Ritchie.
• C is highly portable i.e., software
written for one computer can be run
on another computer.
• An important feature of C is its ability
to extend itself. A C program is basically
a collection of functions.
Reasons to use C
• Easy to learn & write programs.
• Structured language.
• Many common programs are written in C.
• Programs that are created with C run very quickly.
• It allows you direct control over the very low level aspects of the
computer.
• It was (and still is in some circumstances) the language of choice in
Operating System Development (including all of Unix).
Facts about C
• C was invented to write an operating system called UNIX.
• C is a successor of B language which was introduced around the early 1970s.
• The language was formalized in 1988 by the American National Standard
Institute (ANSI).
• The UNIX OS was totally written in C.
• Today C is the most widely used and popular System Programming Language.
• Most of the state-of-the-art software have been implemented using C.
• Today's most popular Linux OS, Oracle and RDBMS MySQL have been written
in C.
History of C
Year Language Developed by Remarks
1960
ALGOL 60 (Algorithmic
Language)
International Committee Too general, too abstract
1963
CPL (Combined
Programming Language)
Cambridge University
Hard to learn, difficult to
implement
1967
BCPL (Basic Combined
Programming Language)
Martin Richards at Cambridge
University
Could deal with only specific
problems
1970 B Ken Thompson at AT & T Bell Labs
Could deal with only specific
problems
1972 C Dennis Ritchie in AT & T Bell Labs Structured Programing
Martin Richards Ken Thompson Dennis Ritchie Ken Thompson & Dennis Ritchie
What is Computer Programming
• A computer program is just a collection of the instructions
necessary to solve a specific problem.
• A program is a set of instruction that tell a computer what to
do.
• Computer Programming is the process of creating computer
programs.
• A program is creating using a programming language.
• A programming language is a language that can be used to
communicate with a computer.
• So for as programming language concern these are of two
types.
1) Machine Oriented (Low/Middle level language)
2) Problem Oriented (High level language)
But C is considered as a Middle level Language. C is modular,
portable, reusable.
Getting Started with C
Steps in learning English language:
Steps in learning C:
Alphabets Words Sentence Paragraphs
Alphabets, Digits &
Special Symbols
Constants, Variables &
Keywords Instructions Program
C Tokens
• A token is an atomic unit (smallest invisible units) in a
program.
• The most basic elements in a C program recognized by the
compiler are a single character or a group of characters called
C tokens.
• The compiler cannot breakdown the token any further. For
example, the words main, ‘{’ (brace), ‘(’ (parenthesis) are all
tokens of C program.
Types of tokens
1. Keywords
Example: int, float, double, char, void, while, for
2. Identifiers
Example: main, amount
3. Constants
Example: 12.4, 7894
4. Strings
Example: “Amit”, “Sunday”
5. Special Symbols
Example: [, ], {, }, (, )
6. Operators
Example: +, -, *, /, %
The C Character Set
The C character set includes the upper case letters A to Z, the
lower case a to z, the decimal digits 0 to 9 and certain special
characters.
Alphabets
Digits
Special Symbols
A, B, C,…,X, Y, Z
A, b, c,…,x,y,z
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
~ ! @ # % ^ & * ( ) _ - + = |  { } [ ] ; :
“ ‘ < > , . ?/
Special Symbols
Character/ Symbol Meaning Character/ Symbol Meaning
~ Tilde , Comma
. Period ; Semicolon
? Question mark : Colon
“ Double quote ‘ Single quote
( Left parenthesis ) Right parenthesis
[ Left bracket ] Right bracket
{ Left brace } Right brace
/ Slash  Back slash
< Less than > Greater than
= Equal to ! Exclamatory mark
- Minus + Plus
# Hash $ Dollar sign
& Ampersand * Asterisk
% Percent ^ Carat
_ Underscore | Vertical bar
Identifiers in C
• Identifiers are the name used to identify a constant, variable, function, or any other
user defined item.
• An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero
or more letters, underscores, and digits (0 to 9).
• No commas or blank space are allowed within a variable name.
• C does not allow punctuation characters such as @, $, and % within identifiers.
• C is a case-sensitive programming language. Thus, Manpower and manpower are
two different identifiers in C.
Mohd zara abc move_name a_123
Myname50 _temp j a23b9 retVal
Keywords in C
• Keywords are predefined tokens in C. These are also called reserved words.
• Keywords have special meaning to the C Compiler. These keywords can be used only
for their intended action; they cannot be used for any other purpose.
• C has 32 keywords.
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
contiune for signed void
default goto sizeof volatile
do if static while
Data Types
•A data type defines a set of values and the operations
that can be performed on them.
•Every datatype item (constant, variable etc.) in C
program has a datatype associated with it.
•C also has a special datatype called void, which,
indicates that any data type, i.e., no data type, does not
describe the data items.
Primitive Data Type
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
contiune for signed void
default goto sizeof volatile
do if static while
Primitive Data Type
Data types Description Size (No. of Bytes) Range
Char Single Character 1 0 to 255
Int An Interger 2 -32,768 to +32,767
Float Float point number 4
-2,147,483,648 to
+2,147,483,647
Double Float point number 8
Approx. 15 digits of
Precision
Void No data type 0
Signed char Character 1 -128 to 127
Unsigned char Unsigned character 1 0 to 255
Short signed int Short signed integer 2 -32,768 to +32,767
Short unsigned int
Short unsigned
interger
3 0 to 65,535
Long singned int Long signed integer 4
-2,147,483,648 to
+2,147,483,647
Constants in C
A constant is a literal, which remain unchanged during the execution of
a program.
A constant is a fixed value that cannot be altered during execution of
program.
C constants can be classified into two categories:
Primary Constants Secondary Constants
Integer Constants Array
Real Constants Pointer
Character Constants Structure
Union
Enum
Rules for Construction Integer Constants
An integer constant must have at least one digit.
It should not contain either a decimal point or exponent.
If a constant is positive, it may or not be preceded by a plus sign. If it is
a negative, it must be preceded by minus sign.
Commas, blanks and non-digit characters are not allowed in integer
constants.
The value of integer constant cannot exceed specified limits.
The valid range is
-32,768 to +32,767
Real Constants
Real values are often called floating-point constants. There are two
ways to represent a real constant decimal form and exponential form.
In exponential form of representation, the real constant is represented
in two parts. The part appearing before ‘e’ is called mantissa, whereas
the part following ‘e’ is called exponent.
Rules for Construction Real Constants
The mantissa part and the exponential part should be separate by a
letter ‘e’.
The mantissa part may have a positive or negative sign.
Default sign of mantissa part is positive.
The exponent must have at least one digit, which must be a positive or
negative integer. Default sign is positive.
Range of real constants expressed in exponential form is
-3.4e38 to 3.4e38.
Rules for Construction Character Constants
A character constant is a single alphabet, a single digit or a single
special symbol enclosed within single inverted commas. Both the
inverted commas point to the left. For example, ‘A’ is valid charcter
constant whereas A is not.
 The maximum length of a character constant can be 1 character.
Note: Every character has its ASCII (American Standard Code for
Information Interchange) value. That means every character is
interchange with integer constant. For example, ‘A’ value is 65 and ‘a’
value is 97.
String Constants
A string constant is a sequence of character enclosed in double quotes.
The character may be letter, number, blank space or special character.
Note that “” is null string or empty string. And the single string
constant is “A” is not equivalent to the single character constant ‘A’.
Each String constant must end with a special character ‘o’. This
character is called null character and used to terminate the string. The
compiler automatically places a null ‘o’ character at the end of every
string constant.
Escape sequence
Some non-printing characters and some other character such as double
quote (“), single quote (‘), question mark (?) and backslash (), required
an escape sequence. A list of commonly used backslash character
constants is given below:
Escape
Sequence
Meaning ASCII Value
Escape
Sequence
Meaning ASCII Value
a Bell 7 r Carriage return 13
b Back Space 8 ” Double quote 34
t Tab 9 ’ Single quote 39
n New line 10 ? Question mark 63
v Vertical tab 11  Back slash 92
f Form feed 12 0 Null 0
Variables in C
• A variable can be considered as a name given to the location
in memory.
• The term variable is used to denote any value that is referred
to a name instead of explicit value.
• A variable is able to hold different value during execution of a
program, where as a constant is restricted to just one value.
• For example, in the equation 2x+3y=10; since x and y can
change, they are variables, where as 2, 3 and 10 cannot
change, hence they are constants. The total equation is known
as expression.
Rules for Construction Variable Names
The name of a variable is composed of one to several characters, the
first of which must be a letter .
No special characters other than letters, digits, and underscore can be
used in variable name. Some compilers permit underscore as the first
character.
Commas or Blanks are not allowed with in a variable name.
Upper case and Lower case letters are significant. That is the variable
“income” is not same as “INCOME”.
The variable name should not be a C key word. Also it should not have
the same name as a function that is written either by user or already
exist in the C library.
C Instructions
There are basically four types of instructions in C:
Type Declaration Instruction
Input/Output Instruction
Arithmetic Instruction
Control Instruction
The purpose of each instructions
Type Declaration instruction To declare the type of variables used in
a C program
Input/Output instruction To perform the function of supplying
input data to a program and obtaining
the output results from it.
Arithmetic instruction To perform arithmetic operations
between constants and variables.
Control instruction To control the sequence of execution of
various statement in a C program.
Operations & Expressions
 An operator is a symbol that tells the computer to perform
certain mathematical or logical manipulations.
 Operators are used in program to manipulate data and
variables. The data items that operators act upon are called
operands.
 Some operators require two operands, while others act upon
only one operand. The operators are classified into unary,
binary and ternary depending on whether they operate on
one, two or three operands respectively.
Types of operators
C has four classes of operators
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bit-wise Operators
In addition, C has some special operators, which are unique to
C, they are
1. Increment & Decrement Operators
2. Conditional Operators
3. Assignment Operators, etc.
Arithmetic Operators
There are five arithmetic operators in C.
The following table lists the arithmetic operators allowed in C:
Operator Meaning
+ Addition
- Subtraction; also for unary minus
* Multiplication
/ Division
% Modulo division (remainder after integer division)
Structure of C Program
1. Documentation Section (Comment Line)
1. // Single line Comment
2. /* Multiple line Comment */
2. Link Section (Header files means Predefined Fuctions)
1. #include <stdio.h>
2. #include <conio.h>
3. #include <math.h>
4. #include <graphics.h>
Structure of C Program
3. Definition Section (Symbolic Constant)
1. #define MAX 50
4. Global Declaration Section (Global Variables)
1. PI= 3.14159,
2. A=10, B=20;
5. Main Function
1. Declaration Part (Local Variable)
2. Executable Part (Statements)
Structure of C Program
6. Sub-Program Section (User Defined Functions)
1. Function-1
2. Function-2
3. Function-3
4. Function-n
Structure of C Program
1. Comment line
2. Preprocessor directive
3. Global variable declaration
4. main function( )
{
Local variables;
Statements;
}
User defined function
{
}
First Program in C
#include<stdio.h> // standard input output header
#include<conio.h> // console input output header
main() // start of main function
{
clrscr(); // predefined function for clear screen
printf(“Hello World”); // predefined function for print
getch(); // for hold screen till user response
} // end of main function
Save the source file with extension filename.c

More Related Content

What's hot (20)

PPSX
Type conversion
Frijo Francis
 
PDF
Python exception handling
Mohammed Sikander
 
PPTX
Character set of c
Chandrapriya Rediex
 
PPTX
Introduction to c programming
Manoj Tyagi
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PDF
Python basic
Saifuddin Kaijar
 
PPTX
Call by value or call by reference in C++
Sachin Yadav
 
PPTX
Data types in java
HarshitaAshwani
 
PDF
Lesson 03 python statement, indentation and comments
Nilimesh Halder
 
PPTX
Basic programming concepts
salmankhan570
 
PPT
Class and object in C++
rprajat007
 
PDF
Object oriented programming c++
Ankur Pandey
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
C++ Memory Management
Rahul Jamwal
 
PPTX
Basics of JAVA programming
Elizabeth Thomas
 
PPTX
Compiler vs interpreter
Paras Patel
 
PPTX
Formatted Console I/O Operations in C++
sujathavvv
 
PPTX
Java
Tony Nguyen
 
PPT
C program
AJAL A J
 
PDF
Introduction to Python
Mohammed Sikander
 
Type conversion
Frijo Francis
 
Python exception handling
Mohammed Sikander
 
Character set of c
Chandrapriya Rediex
 
Introduction to c programming
Manoj Tyagi
 
Oop c++class(final).ppt
Alok Kumar
 
Python basic
Saifuddin Kaijar
 
Call by value or call by reference in C++
Sachin Yadav
 
Data types in java
HarshitaAshwani
 
Lesson 03 python statement, indentation and comments
Nilimesh Halder
 
Basic programming concepts
salmankhan570
 
Class and object in C++
rprajat007
 
Object oriented programming c++
Ankur Pandey
 
Data Types and Variables In C Programming
Kamal Acharya
 
C++ Memory Management
Rahul Jamwal
 
Basics of JAVA programming
Elizabeth Thomas
 
Compiler vs interpreter
Paras Patel
 
Formatted Console I/O Operations in C++
sujathavvv
 
C program
AJAL A J
 
Introduction to Python
Mohammed Sikander
 

Similar to Programming in c (20)

PPTX
Introduction to C language programming.pptx
OVIDMAMAH
 
DOCX
C and DS -unit 1 -Artificial Intelligence and ML.docx
msurfudeen6681
 
PPT
All C ppt.ppt
JeelBhanderi4
 
PPT
C presentation book
krunal1210
 
PDF
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
PDF
C PADHLO FRANDS.pdf
RishiBhardwaj65
 
PDF
Basic of the C language
Sachin Verma
 
PPTX
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
PPT
Basics of C.ppt
ssuserc8fc691
 
PPT
Basics of C.ppt
MITSINDHAV2
 
PPT
Basics of C.ppt
ChiranjeevivarmaP
 
PPT
Basics of C.ppt
TanuGohel
 
PPT
Basiscs of c++ include variable, special characters
E.M.G.yadava womens college
 
PPT
Basics of C (1).ppt
SteveIrwin25
 
PPT
Basics of C.ppt
nikitha992646
 
PPT
Basics of C.ppt
kabhinavin
 
PPT
Basics of C--C Basics------------------.ppt
Ravi Chandra Medisetty
 
PPT
Basics of C (1).ppt
HeshamMohamed855920
 
PPT
Basics of C.ppt
KrishKumar690406
 
PPT
Basics of C.ppt
MEHALAS3
 
Introduction to C language programming.pptx
OVIDMAMAH
 
C and DS -unit 1 -Artificial Intelligence and ML.docx
msurfudeen6681
 
All C ppt.ppt
JeelBhanderi4
 
C presentation book
krunal1210
 
Learning c - An extensive guide to learn the C Language
Abhishek Dwivedi
 
C PADHLO FRANDS.pdf
RishiBhardwaj65
 
Basic of the C language
Sachin Verma
 
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
Basics of C.ppt
ssuserc8fc691
 
Basics of C.ppt
MITSINDHAV2
 
Basics of C.ppt
ChiranjeevivarmaP
 
Basics of C.ppt
TanuGohel
 
Basiscs of c++ include variable, special characters
E.M.G.yadava womens college
 
Basics of C (1).ppt
SteveIrwin25
 
Basics of C.ppt
nikitha992646
 
Basics of C.ppt
kabhinavin
 
Basics of C--C Basics------------------.ppt
Ravi Chandra Medisetty
 
Basics of C (1).ppt
HeshamMohamed855920
 
Basics of C.ppt
KrishKumar690406
 
Basics of C.ppt
MEHALAS3
 
Ad

Recently uploaded (20)

PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Ad

Programming in c

  • 2. Introducing of C • C is a programming language developed at AT & T Bell Laboratories of USA in 1972, designed and written by Dennis Ritchie. • C is highly portable i.e., software written for one computer can be run on another computer. • An important feature of C is its ability to extend itself. A C program is basically a collection of functions.
  • 3. Reasons to use C • Easy to learn & write programs. • Structured language. • Many common programs are written in C. • Programs that are created with C run very quickly. • It allows you direct control over the very low level aspects of the computer. • It was (and still is in some circumstances) the language of choice in Operating System Development (including all of Unix).
  • 4. Facts about C • C was invented to write an operating system called UNIX. • C is a successor of B language which was introduced around the early 1970s. • The language was formalized in 1988 by the American National Standard Institute (ANSI). • The UNIX OS was totally written in C. • Today C is the most widely used and popular System Programming Language. • Most of the state-of-the-art software have been implemented using C. • Today's most popular Linux OS, Oracle and RDBMS MySQL have been written in C.
  • 5. History of C Year Language Developed by Remarks 1960 ALGOL 60 (Algorithmic Language) International Committee Too general, too abstract 1963 CPL (Combined Programming Language) Cambridge University Hard to learn, difficult to implement 1967 BCPL (Basic Combined Programming Language) Martin Richards at Cambridge University Could deal with only specific problems 1970 B Ken Thompson at AT & T Bell Labs Could deal with only specific problems 1972 C Dennis Ritchie in AT & T Bell Labs Structured Programing Martin Richards Ken Thompson Dennis Ritchie Ken Thompson & Dennis Ritchie
  • 6. What is Computer Programming • A computer program is just a collection of the instructions necessary to solve a specific problem. • A program is a set of instruction that tell a computer what to do. • Computer Programming is the process of creating computer programs. • A program is creating using a programming language. • A programming language is a language that can be used to communicate with a computer. • So for as programming language concern these are of two types. 1) Machine Oriented (Low/Middle level language) 2) Problem Oriented (High level language) But C is considered as a Middle level Language. C is modular, portable, reusable.
  • 7. Getting Started with C Steps in learning English language: Steps in learning C: Alphabets Words Sentence Paragraphs Alphabets, Digits & Special Symbols Constants, Variables & Keywords Instructions Program
  • 8. C Tokens • A token is an atomic unit (smallest invisible units) in a program. • The most basic elements in a C program recognized by the compiler are a single character or a group of characters called C tokens. • The compiler cannot breakdown the token any further. For example, the words main, ‘{’ (brace), ‘(’ (parenthesis) are all tokens of C program.
  • 9. Types of tokens 1. Keywords Example: int, float, double, char, void, while, for 2. Identifiers Example: main, amount 3. Constants Example: 12.4, 7894 4. Strings Example: “Amit”, “Sunday” 5. Special Symbols Example: [, ], {, }, (, ) 6. Operators Example: +, -, *, /, %
  • 10. The C Character Set The C character set includes the upper case letters A to Z, the lower case a to z, the decimal digits 0 to 9 and certain special characters. Alphabets Digits Special Symbols A, B, C,…,X, Y, Z A, b, c,…,x,y,z 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ~ ! @ # % ^ & * ( ) _ - + = | { } [ ] ; : “ ‘ < > , . ?/
  • 11. Special Symbols Character/ Symbol Meaning Character/ Symbol Meaning ~ Tilde , Comma . Period ; Semicolon ? Question mark : Colon “ Double quote ‘ Single quote ( Left parenthesis ) Right parenthesis [ Left bracket ] Right bracket { Left brace } Right brace / Slash Back slash < Less than > Greater than = Equal to ! Exclamatory mark - Minus + Plus # Hash $ Dollar sign & Ampersand * Asterisk % Percent ^ Carat _ Underscore | Vertical bar
  • 12. Identifiers in C • Identifiers are the name used to identify a constant, variable, function, or any other user defined item. • An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9). • No commas or blank space are allowed within a variable name. • C does not allow punctuation characters such as @, $, and % within identifiers. • C is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C. Mohd zara abc move_name a_123 Myname50 _temp j a23b9 retVal
  • 13. Keywords in C • Keywords are predefined tokens in C. These are also called reserved words. • Keywords have special meaning to the C Compiler. These keywords can be used only for their intended action; they cannot be used for any other purpose. • C has 32 keywords. auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned contiune for signed void default goto sizeof volatile do if static while
  • 14. Data Types •A data type defines a set of values and the operations that can be performed on them. •Every datatype item (constant, variable etc.) in C program has a datatype associated with it. •C also has a special datatype called void, which, indicates that any data type, i.e., no data type, does not describe the data items.
  • 15. Primitive Data Type auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned contiune for signed void default goto sizeof volatile do if static while
  • 16. Primitive Data Type Data types Description Size (No. of Bytes) Range Char Single Character 1 0 to 255 Int An Interger 2 -32,768 to +32,767 Float Float point number 4 -2,147,483,648 to +2,147,483,647 Double Float point number 8 Approx. 15 digits of Precision Void No data type 0 Signed char Character 1 -128 to 127 Unsigned char Unsigned character 1 0 to 255 Short signed int Short signed integer 2 -32,768 to +32,767 Short unsigned int Short unsigned interger 3 0 to 65,535 Long singned int Long signed integer 4 -2,147,483,648 to +2,147,483,647
  • 17. Constants in C A constant is a literal, which remain unchanged during the execution of a program. A constant is a fixed value that cannot be altered during execution of program. C constants can be classified into two categories: Primary Constants Secondary Constants Integer Constants Array Real Constants Pointer Character Constants Structure Union Enum
  • 18. Rules for Construction Integer Constants An integer constant must have at least one digit. It should not contain either a decimal point or exponent. If a constant is positive, it may or not be preceded by a plus sign. If it is a negative, it must be preceded by minus sign. Commas, blanks and non-digit characters are not allowed in integer constants. The value of integer constant cannot exceed specified limits. The valid range is -32,768 to +32,767
  • 19. Real Constants Real values are often called floating-point constants. There are two ways to represent a real constant decimal form and exponential form. In exponential form of representation, the real constant is represented in two parts. The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.
  • 20. Rules for Construction Real Constants The mantissa part and the exponential part should be separate by a letter ‘e’. The mantissa part may have a positive or negative sign. Default sign of mantissa part is positive. The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive. Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
  • 21. Rules for Construction Character Constants A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas point to the left. For example, ‘A’ is valid charcter constant whereas A is not.  The maximum length of a character constant can be 1 character. Note: Every character has its ASCII (American Standard Code for Information Interchange) value. That means every character is interchange with integer constant. For example, ‘A’ value is 65 and ‘a’ value is 97.
  • 22. String Constants A string constant is a sequence of character enclosed in double quotes. The character may be letter, number, blank space or special character. Note that “” is null string or empty string. And the single string constant is “A” is not equivalent to the single character constant ‘A’. Each String constant must end with a special character ‘o’. This character is called null character and used to terminate the string. The compiler automatically places a null ‘o’ character at the end of every string constant.
  • 23. Escape sequence Some non-printing characters and some other character such as double quote (“), single quote (‘), question mark (?) and backslash (), required an escape sequence. A list of commonly used backslash character constants is given below: Escape Sequence Meaning ASCII Value Escape Sequence Meaning ASCII Value a Bell 7 r Carriage return 13 b Back Space 8 ” Double quote 34 t Tab 9 ’ Single quote 39 n New line 10 ? Question mark 63 v Vertical tab 11 Back slash 92 f Form feed 12 0 Null 0
  • 24. Variables in C • A variable can be considered as a name given to the location in memory. • The term variable is used to denote any value that is referred to a name instead of explicit value. • A variable is able to hold different value during execution of a program, where as a constant is restricted to just one value. • For example, in the equation 2x+3y=10; since x and y can change, they are variables, where as 2, 3 and 10 cannot change, hence they are constants. The total equation is known as expression.
  • 25. Rules for Construction Variable Names The name of a variable is composed of one to several characters, the first of which must be a letter . No special characters other than letters, digits, and underscore can be used in variable name. Some compilers permit underscore as the first character. Commas or Blanks are not allowed with in a variable name. Upper case and Lower case letters are significant. That is the variable “income” is not same as “INCOME”. The variable name should not be a C key word. Also it should not have the same name as a function that is written either by user or already exist in the C library.
  • 26. C Instructions There are basically four types of instructions in C: Type Declaration Instruction Input/Output Instruction Arithmetic Instruction Control Instruction
  • 27. The purpose of each instructions Type Declaration instruction To declare the type of variables used in a C program Input/Output instruction To perform the function of supplying input data to a program and obtaining the output results from it. Arithmetic instruction To perform arithmetic operations between constants and variables. Control instruction To control the sequence of execution of various statement in a C program.
  • 28. Operations & Expressions  An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations.  Operators are used in program to manipulate data and variables. The data items that operators act upon are called operands.  Some operators require two operands, while others act upon only one operand. The operators are classified into unary, binary and ternary depending on whether they operate on one, two or three operands respectively.
  • 29. Types of operators C has four classes of operators 1. Arithmetic Operators 2. Relational Operators 3. Logical Operators 4. Bit-wise Operators In addition, C has some special operators, which are unique to C, they are 1. Increment & Decrement Operators 2. Conditional Operators 3. Assignment Operators, etc.
  • 30. Arithmetic Operators There are five arithmetic operators in C. The following table lists the arithmetic operators allowed in C: Operator Meaning + Addition - Subtraction; also for unary minus * Multiplication / Division % Modulo division (remainder after integer division)
  • 31. Structure of C Program 1. Documentation Section (Comment Line) 1. // Single line Comment 2. /* Multiple line Comment */ 2. Link Section (Header files means Predefined Fuctions) 1. #include <stdio.h> 2. #include <conio.h> 3. #include <math.h> 4. #include <graphics.h>
  • 32. Structure of C Program 3. Definition Section (Symbolic Constant) 1. #define MAX 50 4. Global Declaration Section (Global Variables) 1. PI= 3.14159, 2. A=10, B=20; 5. Main Function 1. Declaration Part (Local Variable) 2. Executable Part (Statements)
  • 33. Structure of C Program 6. Sub-Program Section (User Defined Functions) 1. Function-1 2. Function-2 3. Function-3 4. Function-n
  • 34. Structure of C Program 1. Comment line 2. Preprocessor directive 3. Global variable declaration 4. main function( ) { Local variables; Statements; } User defined function { }
  • 35. First Program in C #include<stdio.h> // standard input output header #include<conio.h> // console input output header main() // start of main function { clrscr(); // predefined function for clear screen printf(“Hello World”); // predefined function for print getch(); // for hold screen till user response } // end of main function Save the source file with extension filename.c