SlideShare a Scribd company logo
Basics of “C” Programming
Powered By
Er. Shibdas Dutta
Dean- SOIT
IAER-KOLKATA
Terminologies of ‘C’
1. Keywords
2. Identifiers
3. Variables
4. Constants
5. Special Symbols
6. Operators
7. Character & String
1. Keywords
• Keywords are the reserved words whose meaning has already
been explained to the C compiler.
• C has 32 keywords.
• These keywords combined with a formal syntax form a C
programming language.
• Rules to be followed for all programs written in C:
All keywords are lower-cased.
C is case sensitive, do-while is different from DO WHILE.
Keywords cannot be used as a variable or function name.
2. Identifiers
• Identifiers refer to the name of variables, functions and arrays.
• These are user-defined names and consist of sequence of letters
and digits, with a letter as a first character.
• Both uppercase and lowercase letters are permitted, although
lowercase letters are commonly used .
• The underscore character is also permitted in identifiers. It is
usually used as a link between two words in long identifiers.
Identifier Names
Some correct identifier names are -
arena, s_count
marks40
class_one
Some erroneous identifier names are -
1stsst
oh!god
start….end

X
The number of characters in the variable that are
recognized differs from compiler to compiler
An identifier cannot be the same as a C keyword
3. Variables
• Variables are named locations in memory that are used to hold
a value that may be modified by the program.
• Unlike constants that remain unchanged during the execution
of a program.
• A variable may take different values at different times during
execution.
• The syntax for declaring a variable is –
DataType IdentifierName ;
• Example- int num;
long int sum , a;
4. Constants
• Constants are the fixed values that do not change
during the execution of a program.
• C supports several types of constants.
– Numeric Constants
• Integer constants
• Real constants
– Character Constants
• Single character constant
• String Constants
5. Special Symbols
• ! , @, #, $ , & , * , ….. These all symbols that can be
find on Keyboard, are called Special Symbols.
• Every symbol has its special meaning in different respect
at different place that’s why it is called Special Symbols.
6. Operators
• Operator is a symbol that operates on one or more
operands and produces output.
Example - c = a + b ;
• In the above Example the symbols + and = are
operators that operate on operands a, b , and c .
7. Character & String
• The Characters that can be used to form words,
numbers and expressions depend upon the computer
on which the program is running.
• The characters in C are grouped into the following
categories :
– Letters
– Digits
– Special characters
– White Spaces
• Remember that a character ‘a’ is not equivalent to the
string “a”.
Why use C?
• Mainly because it produces code that runs nearly as fast as
code written in assembly language. Some examples of the use
of C might be:
– Operating Systems
– Language Compilers
– Assemblers
– Text Editors
– Print Spoolers
– Network Drivers
– Modern Programs
– Data Bases
– Language Interpreters
– Utilities
Why C Still Useful?
• C provides:
 Efficiency, high performance and high quality
 flexibility and power
 many high-level and low-level operations  middle level
 Stability and small size code
 Provide functionality through rich set of function libraries
 Gateway for other professional languages like C  C++  Java
• C is used:
 System software Compilers, Editors, embedded systems
 data compression, graphics and computational geometry, utility
programs
 databases, operating systems, device drivers, system level
routines
 there are zillions of lines of C legacy code
 Also used in application programs
Software Development Method
• Requirement Specification
– Problem Definition
• Analysis
– Refine, Generalize, Decompose the problem definition
• Design
– Develop Algorithm
• Implementation
– Write Code
• Verification and Testing
– Test and Debug the code
Development with C
• Four stages
 Editing: Writing the source code by using some IDE or editor
 Preprocessing or libraries: Already available routines
 compiling: translates or converts source to object code for a
specific platform source code -> object code
 linking: resolves external references and produces the
executable module
 Portable programs will run on any machine but…..
 Program correctness and robustness are most important than
program efficiency
History
• In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the
publication of The C Programming Language by Kernighan
& Ritchie caused a revolution in the computing world
• In 1983, the American National Standards Institute (ANSI)
established a committee to provide a modern, comprehensive
definition of C. The resulting definition, the ANSI standard, or
"ANSI C", was completed late 1988.
The Beginning of C
History of C
• Evolved from two previous languages
– BCPL , B
• BCPL (Basic Combined Programming Language) used for
writing OS & compilers
• B used for creating early versions of UNIX OS
• Both were “typeless” languages
• C language evolved from B (Dennis Ritchie – Bell labs)
• C was developed by Dennis Ritchie at AT & T bell laboratory
of USA in 1972.
History of C
• Hardware independent
• Programs portable to most computers
• Dialects of C
– Common C
– ANSI C
• ANSI/ ISO 9899: 1990
• Called American National Standards Institute ANSI C
• Case-sensitive
C – A Middle Level Language
C is Middle Level Language
• C stands in between these two categories.
• Since it was designed to have both:
• A relatively good programming efficiency as compared to
Machine Oriented Languages .
• A relatively good Machine efficiency as compared to
Problem Oriented Languages .
• That’s WHY it is called a Middle Level Language.
Application Areas Of C
• C was initially used for systems programming.
• A system program forms a portion of the operating
system of the computer or its support utilities.
• Operating Systems, Interpreters, Editors, Assembly
programs are usually called system programs.
• The UNIX operating system was developed using C.
• There are C compilers available for almost all types
of PC’s.
A simple Program of C
/* Write a program to print a message */
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“ C Programming”);
getch( );
}
 Comment about the program should be enclosed within ‘/*’ &
‘*/’.
 printf() is a function which is used to print messages on the
screen.
 main() is a function from which execution of the program
starts.
 Here stdio.h is a library file which contains standard
input/output functions , keywords etc.
 #include<> is used to define the library file that is to be used
in the program for compiler information.
Compilation & Execution of a Program
C Preprocessor
Expanded C Source Code
C Compiler
Target Assembly Code
Linker
Executable Code
Loader
Output
C Source Code
Basics of C Environment
• C systems consist of 3 parts
– Environment
– Language
– C Standard Library
• Development environment has 6 phases
– Edit
– Pre-processor
– Compile
– Link
– Load
– Execute
Basics of C Environment
Editor Disk
Phase 1
Program edited in
Editor and stored
on disk
Preprocessor Disk
Phase 2
Preprocessor
program processes
the code
Compiler Disk
Phase 3
Creates object code
and stores on disk
Linker Disk
Phase 4
Links object code
with libraries and
stores on disk
Basics of C Environment
Loader
Phase 5
Puts program in
memory
Primary memory
CPU
Phase 6
Takes each instruction
and executes it storing
new data values
Primary memory
Execution Process of a Program
PROCESS SHORT CUT FILE NAME
Save F2 abc.c
Compile Alt + F9 abc.obj
Execute Ctrl + F9 abc.exe
Back up Again F2 abc.bak
Escape Sequence
• n new line
• t tab
• r carriage return
• a alert
•  backslash
• ” double quote
Control FLOW Statements
• C language has decision making capabilities and
supports controlling of statements.
• C supports following decision making statements:
1. IF
2.IF-ELSE and its various form
3. Switch
4. Conditional Operator
If statement
• The if statement is a powerful decision making
statement.
• The if statement is used to control the flow of
execution of statements.
• It is a two way decision statement which is used in
conjunction with an expression.
Different forms of If statement
• Simple If statement.
• If…..else statement.
• Nested if…..else statement.
• Else if ladder.
Simple if statement
• If the if expression evaluates to true, the block
following the if statement or statements are executed.
• The general form of a simple if statement is :
if (test-expression)
{
statement-block;
}
statement-x;
If….Else statement
• The general form of if……else statements is :
• IF the if expression evaluates to true, the block
following the if statement or statements are executed.
• The else statement is optional. It is used only if a
statement or a sequence of statements are to be
executed in case the if expression evaluates to false.
Else if ladder
• The general form of else if ladder is:
• The if – else – if statement is also known as the if-else-if
ladder or the if-else-if staircase.
• The conditions are evaluated from the top downwards.
Nested if…else statement
• The general form of nested if…else statement is:
if (test-expression 1)
{
if (test-expression 2)
{
statement 1;
}
else
{
statement 2;
}
}
else
{
statement 3;
}
Statement x;
Switch – case statement
• The switch-case control statement is a multi-way decision maker that tests
the value of an expression against a list of integers or character constants.
• When a match is found, the statements associated with that constant are
executed.
• The syntax of switch-case is:-
Jumping Statement
• Break
• Continue
• Goto
Break statement
• When the keyword break is encountered inside any c loop,
control automatically passes to the first statement after the
loop.
• A break is usually associated with an if.
• The general syntax of break statement is:
For(; ;)
{
--------
--------
if (error)
break;
-------
}
--------
Continue statement
• In some programming situations we want to take the control to
the beginning of the loop, by passing the statements inside the
loop which have not yet been executed. The Keyword
continue allows us to do this.
• When the keyword continue is encountered inside any C loop,
control automatically passes to the beginning of the loop.
• A continue is usually associated with an if.
#include<stdio.h>
void main()
{
int i,j;
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
if(i==j)
continue;
printf(“%d%d”,i,j);
}
} }
Output 1 2
2 1
Go to statement
• C supports the go to statement to branch unconditionally from
one point to another in the program.
• It requires a label in order to identify the place where branch is
to be made.
• The general syntax of go to statement is:
go to label;
--------
--------
label:
statement x ;

More Related Content

PPTX
Introduction to C programming
PPTX
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
PPTX
PPTX
PPT
C PROGRAMMING
PPT
C intro
PPT
C_Intro.ppt
PPTX
PROGRAMMING IN C - SARASWATHI RAMALINGAM
Introduction to C programming
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C PROGRAMMING
C intro
C_Intro.ppt
PROGRAMMING IN C - SARASWATHI RAMALINGAM

Similar to Basics of C Prog Lang.pdf (20)

PPTX
C Language Presentation.pptx
PPT
The smartpath information systems c pro
PDF
Introduction to C programming
PPTX
Unit ii
PPTX
Basics of C Lecture 2[16097].pptx
PPTX
C language (1).pptxC language (1C language (1).pptx).pptx
PPTX
C programming language:- Introduction to C Programming - Overview and Importa...
PPT
01 c
PPTX
Introduction to c language
PDF
C Language
PPT
What is turbo c and how it works
PDF
Introduction of c language
PPTX
C lang7age programming powerpoint presentation
PPTX
chapter 1.pptx
PPTX
C programming
PPTX
C for Engineers
PPTX
C introduction by thooyavan
DOC
1. introduction to computer
PPTX
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
C Language Presentation.pptx
The smartpath information systems c pro
Introduction to C programming
Unit ii
Basics of C Lecture 2[16097].pptx
C language (1).pptxC language (1C language (1).pptx).pptx
C programming language:- Introduction to C Programming - Overview and Importa...
01 c
Introduction to c language
C Language
What is turbo c and how it works
Introduction of c language
C lang7age programming powerpoint presentation
chapter 1.pptx
C programming
C for Engineers
C introduction by thooyavan
1. introduction to computer
CSE_1201_Lecture_1_Introduction_to_Programming_0fd134f8149173dfa0821f1575f733...
Ad

More from KalighatOkira (6)

PDF
Machine Learning with Python- Machine Learning Algorithms.pdf
PDF
Machine Learning with Python- Machine Learning Algorithms- Naïve Bayes.pdf
PDF
Machine Learning with Python- Machine Learning Algorithms- Logistic Regressio...
PDF
Machine Learning with Python- Machine Learning Algorithms- Decision Tree.pdf
PDF
Machine Learning with Python- Machine Learning Algorithms- Random Forest.pdf
PDF
Machine Learning with Python- Machine Learning Algorithms- K-Means Clustering...
Machine Learning with Python- Machine Learning Algorithms.pdf
Machine Learning with Python- Machine Learning Algorithms- Naïve Bayes.pdf
Machine Learning with Python- Machine Learning Algorithms- Logistic Regressio...
Machine Learning with Python- Machine Learning Algorithms- Decision Tree.pdf
Machine Learning with Python- Machine Learning Algorithms- Random Forest.pdf
Machine Learning with Python- Machine Learning Algorithms- K-Means Clustering...
Ad

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT
Project quality management in manufacturing
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Artificial Intelligence
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Sustainable Sites - Green Building Construction
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
573137875-Attendance-Management-System-original
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
Construction Project Organization Group 2.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Digital Logic Computer Design lecture notes
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
web development for engineering and engineering
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Project quality management in manufacturing
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Artificial Intelligence
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Automation-in-Manufacturing-Chapter-Introduction.pdf
Sustainable Sites - Green Building Construction
additive manufacturing of ss316l using mig welding
Foundation to blockchain - A guide to Blockchain Tech
573137875-Attendance-Management-System-original
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Construction Project Organization Group 2.pptx
OOP with Java - Java Introduction (Basics)
bas. eng. economics group 4 presentation 1.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Digital Logic Computer Design lecture notes
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
web development for engineering and engineering
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

Basics of C Prog Lang.pdf

  • 1. Basics of “C” Programming Powered By Er. Shibdas Dutta Dean- SOIT IAER-KOLKATA
  • 2. Terminologies of ‘C’ 1. Keywords 2. Identifiers 3. Variables 4. Constants 5. Special Symbols 6. Operators 7. Character & String
  • 3. 1. Keywords • Keywords are the reserved words whose meaning has already been explained to the C compiler. • C has 32 keywords. • These keywords combined with a formal syntax form a C programming language. • Rules to be followed for all programs written in C: All keywords are lower-cased. C is case sensitive, do-while is different from DO WHILE. Keywords cannot be used as a variable or function name.
  • 4. 2. Identifiers • Identifiers refer to the name of variables, functions and arrays. • These are user-defined names and consist of sequence of letters and digits, with a letter as a first character. • Both uppercase and lowercase letters are permitted, although lowercase letters are commonly used . • The underscore character is also permitted in identifiers. It is usually used as a link between two words in long identifiers.
  • 5. Identifier Names Some correct identifier names are - arena, s_count marks40 class_one Some erroneous identifier names are - 1stsst oh!god start….end  X The number of characters in the variable that are recognized differs from compiler to compiler An identifier cannot be the same as a C keyword
  • 6. 3. Variables • Variables are named locations in memory that are used to hold a value that may be modified by the program. • Unlike constants that remain unchanged during the execution of a program. • A variable may take different values at different times during execution. • The syntax for declaring a variable is – DataType IdentifierName ; • Example- int num; long int sum , a;
  • 7. 4. Constants • Constants are the fixed values that do not change during the execution of a program. • C supports several types of constants. – Numeric Constants • Integer constants • Real constants – Character Constants • Single character constant • String Constants
  • 8. 5. Special Symbols • ! , @, #, $ , & , * , ….. These all symbols that can be find on Keyboard, are called Special Symbols. • Every symbol has its special meaning in different respect at different place that’s why it is called Special Symbols.
  • 9. 6. Operators • Operator is a symbol that operates on one or more operands and produces output. Example - c = a + b ; • In the above Example the symbols + and = are operators that operate on operands a, b , and c .
  • 10. 7. Character & String • The Characters that can be used to form words, numbers and expressions depend upon the computer on which the program is running. • The characters in C are grouped into the following categories : – Letters – Digits – Special characters – White Spaces • Remember that a character ‘a’ is not equivalent to the string “a”.
  • 11. Why use C? • Mainly because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be: – Operating Systems – Language Compilers – Assemblers – Text Editors – Print Spoolers – Network Drivers – Modern Programs – Data Bases – Language Interpreters – Utilities
  • 12. Why C Still Useful? • C provides:  Efficiency, high performance and high quality  flexibility and power  many high-level and low-level operations  middle level  Stability and small size code  Provide functionality through rich set of function libraries  Gateway for other professional languages like C  C++  Java • C is used:  System software Compilers, Editors, embedded systems  data compression, graphics and computational geometry, utility programs  databases, operating systems, device drivers, system level routines  there are zillions of lines of C legacy code  Also used in application programs
  • 13. Software Development Method • Requirement Specification – Problem Definition • Analysis – Refine, Generalize, Decompose the problem definition • Design – Develop Algorithm • Implementation – Write Code • Verification and Testing – Test and Debug the code
  • 14. Development with C • Four stages  Editing: Writing the source code by using some IDE or editor  Preprocessing or libraries: Already available routines  compiling: translates or converts source to object code for a specific platform source code -> object code  linking: resolves external references and produces the executable module  Portable programs will run on any machine but…..  Program correctness and robustness are most important than program efficiency
  • 15. History • In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the publication of The C Programming Language by Kernighan & Ritchie caused a revolution in the computing world • In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSI C", was completed late 1988.
  • 17. History of C • Evolved from two previous languages – BCPL , B • BCPL (Basic Combined Programming Language) used for writing OS & compilers • B used for creating early versions of UNIX OS • Both were “typeless” languages • C language evolved from B (Dennis Ritchie – Bell labs) • C was developed by Dennis Ritchie at AT & T bell laboratory of USA in 1972.
  • 18. History of C • Hardware independent • Programs portable to most computers • Dialects of C – Common C – ANSI C • ANSI/ ISO 9899: 1990 • Called American National Standards Institute ANSI C • Case-sensitive
  • 19. C – A Middle Level Language
  • 20. C is Middle Level Language • C stands in between these two categories. • Since it was designed to have both: • A relatively good programming efficiency as compared to Machine Oriented Languages . • A relatively good Machine efficiency as compared to Problem Oriented Languages . • That’s WHY it is called a Middle Level Language.
  • 21. Application Areas Of C • C was initially used for systems programming. • A system program forms a portion of the operating system of the computer or its support utilities. • Operating Systems, Interpreters, Editors, Assembly programs are usually called system programs. • The UNIX operating system was developed using C. • There are C compilers available for almost all types of PC’s.
  • 22. A simple Program of C /* Write a program to print a message */ #include<stdio.h> #include<conio.h> void main() { printf(“ C Programming”); getch( ); }
  • 23.  Comment about the program should be enclosed within ‘/*’ & ‘*/’.  printf() is a function which is used to print messages on the screen.  main() is a function from which execution of the program starts.  Here stdio.h is a library file which contains standard input/output functions , keywords etc.  #include<> is used to define the library file that is to be used in the program for compiler information.
  • 24. Compilation & Execution of a Program C Preprocessor Expanded C Source Code C Compiler Target Assembly Code Linker Executable Code Loader Output C Source Code
  • 25. Basics of C Environment • C systems consist of 3 parts – Environment – Language – C Standard Library • Development environment has 6 phases – Edit – Pre-processor – Compile – Link – Load – Execute
  • 26. Basics of C Environment Editor Disk Phase 1 Program edited in Editor and stored on disk Preprocessor Disk Phase 2 Preprocessor program processes the code Compiler Disk Phase 3 Creates object code and stores on disk Linker Disk Phase 4 Links object code with libraries and stores on disk
  • 27. Basics of C Environment Loader Phase 5 Puts program in memory Primary memory CPU Phase 6 Takes each instruction and executes it storing new data values Primary memory
  • 28. Execution Process of a Program PROCESS SHORT CUT FILE NAME Save F2 abc.c Compile Alt + F9 abc.obj Execute Ctrl + F9 abc.exe Back up Again F2 abc.bak
  • 29. Escape Sequence • n new line • t tab • r carriage return • a alert • backslash • ” double quote
  • 30. Control FLOW Statements • C language has decision making capabilities and supports controlling of statements. • C supports following decision making statements: 1. IF 2.IF-ELSE and its various form 3. Switch 4. Conditional Operator
  • 31. If statement • The if statement is a powerful decision making statement. • The if statement is used to control the flow of execution of statements. • It is a two way decision statement which is used in conjunction with an expression.
  • 32. Different forms of If statement • Simple If statement. • If…..else statement. • Nested if…..else statement. • Else if ladder.
  • 33. Simple if statement • If the if expression evaluates to true, the block following the if statement or statements are executed. • The general form of a simple if statement is : if (test-expression) { statement-block; } statement-x;
  • 34. If….Else statement • The general form of if……else statements is : • IF the if expression evaluates to true, the block following the if statement or statements are executed. • The else statement is optional. It is used only if a statement or a sequence of statements are to be executed in case the if expression evaluates to false.
  • 35. Else if ladder • The general form of else if ladder is: • The if – else – if statement is also known as the if-else-if ladder or the if-else-if staircase. • The conditions are evaluated from the top downwards.
  • 36. Nested if…else statement • The general form of nested if…else statement is: if (test-expression 1) { if (test-expression 2) { statement 1; } else { statement 2; } } else { statement 3; } Statement x;
  • 37. Switch – case statement • The switch-case control statement is a multi-way decision maker that tests the value of an expression against a list of integers or character constants. • When a match is found, the statements associated with that constant are executed. • The syntax of switch-case is:-
  • 38. Jumping Statement • Break • Continue • Goto
  • 39. Break statement • When the keyword break is encountered inside any c loop, control automatically passes to the first statement after the loop. • A break is usually associated with an if. • The general syntax of break statement is: For(; ;) { -------- -------- if (error) break; ------- } --------
  • 40. Continue statement • In some programming situations we want to take the control to the beginning of the loop, by passing the statements inside the loop which have not yet been executed. The Keyword continue allows us to do this. • When the keyword continue is encountered inside any C loop, control automatically passes to the beginning of the loop. • A continue is usually associated with an if.
  • 43. Go to statement • C supports the go to statement to branch unconditionally from one point to another in the program. • It requires a label in order to identify the place where branch is to be made. • The general syntax of go to statement is: go to label; -------- -------- label: statement x ;