SlideShare a Scribd company logo
Dinesh Maharjan, 2022
Programming in C
Elements of C
Instructor: Dinesh Maharjan
2022
• C was introduced by Brian Kernighan and Dennis
Ritchie in 1978 to develop unix operating system at
Bell Labs.
• This version of C is known as K&R C (1972-1989).
• Essentially all unix applications are written in C.
• C is a successor of B language.
• C is portable.
• C programs are as fast as the assembly programs
• C is widely used as the system programming language
C Introduction
• C has now become a widely used professional
language for
• Easy to learn
• Structured language
• Can be compiled on variety of computers.
• C uses low level features such as chracters, numbers
and addresses.
• C operators does not work on composite data types
such as strings, arrays, sets
C Introduction
C Introduction
• Initially, C is known as K&R C (1972-1989).
• Later it was standardized by ANSI in 1989 known as
ANSI- C or C89.
• C was internationally accepted and was standardized
by ISO in 1990 known as The C language or C90.
• Minor update was released in 1995 as C95.
• C99 was released in 1999 with major revision.
• C11 was released in 2011 with major focus in multi-
core, multi-processing and expression sequencing.
C Standard
GNU C Compiler (GCC)
• For compiling C language, we need C compiler.
• GNU C Compiler can be used by installing MinGW.
• You should add the path of bin subdirectory of MinGW
installation to PATH environmental variable.
GNU C Compiler (GCC)
• To run the executable, type a
GNU C Compiler (GCC)
Unit 2 Elements of C.pptx
Tokens
• Building Blocks of C language
• Includes keywords, identifiers, constant, operators,
special symbols
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unary Operator ++, -- Unary Operator
Binary operator
+, -, *, /, % Arithmetic Operator
<, <=, >, >=,==, != Relational Operator
&&, !!, ! Logical Operator
&, |, <<, >>, ~, ^ Bitwise Operator
=, +=, -=, *=, /=, %= Assignment Operator
Ternary Operator ?: Conditional Operator
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
• Special Symbols that separate variables, constants or
statements
• (,) comma separates variables and constant
• ( spacebar) separates keywords, expression
• (;) semicolon separates or ends the statement.
Delimiters
• Instruction to the computer to do certain task.
• Usually one statement per line.
• It can span over multiple lines.
• Ends with ; (Semicolon)
• It is combination of keywords, expression
• X=5*2;
• printf(“Let C”);
Statement
• Compiler ignores white spaces in the statement.
• However white spaces within a string constant is not
ignored.
Statement
Statement
Types of Statement
• Simple statement: x=5+9;
• Null statement: ;
• Compound Statement:
• {
• X=4+8;
• Y=9+9;
• }
Expression
• Combination of operand, operator and function.
• Expression evaluates to some value that can be
numeric or string.
• 4+9
• “b”+”C”
Comments
• Make programs easy to read and modify.
• Comments are removed by compiler before generating
executable.
• Comments is kept inside /* comment */
• It can be multiple lines also.
Structure of a C program
• Preprocessor
• Comments
• Function Prototype
• Main function
• The return type of main function must be int.
• K&R C supports main() without return type.
• Main without return type is defaulted int return type.
• Most of compilers does not support void return type.
#include <stdio.h>
// program prints hello world
int main() {
printf ("Hello world!");
return 0;
}
Output: Hello world!
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptx

More Related Content

PPT
The smartpath information systems c pro
DOCX
Lect '1'
DOCX
Uniti classnotes
DOCX
C programming language Reference Note
PDF
C programming.pdf
PPTX
C Programming - Basics of c -history of c
PPTX
Introduction to C programming
PDF
Basics of C Prog Lang.pdf
The smartpath information systems c pro
Lect '1'
Uniti classnotes
C programming language Reference Note
C programming.pdf
C Programming - Basics of c -history of c
Introduction to C programming
Basics of C Prog Lang.pdf

Similar to Unit 2 Elements of C.pptx (20)

PPTX
Basics of C Lecture 2[16097].pptx
PDF
C class basic programming 1 PPT mayanka (1).pdf
PPTX
C Language ppt create by Anand & Sager.pptx
PDF
C programming introduction for beginners.pdf
PDF
Introduction to C programming
PPTX
C programming Training in Ambala ! Batra Computer Centre
DOC
1. introduction to computer
PPTX
PROGRAMMING IN C - SARASWATHI RAMALINGAM
PPTX
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
PPTX
C introduction by thooyavan
DOCX
C and DS -unit 1 -Artificial Intelligence and ML.docx
PPTX
C lang7age programming powerpoint presentation
PPTX
prateek verbal computer language 2024 .pptx
PPTX
C programming presentation(final)
PPTX
C PROGRAMMING LANGUAGE.pptx
PPT
history of c.ppt
PDF
C programme presentation
PDF
Programming Fundamentals and basic knowledge
PDF
C Programming Language Introduction and C Tokens.pdf
PPT
1. over view and history of c
Basics of C Lecture 2[16097].pptx
C class basic programming 1 PPT mayanka (1).pdf
C Language ppt create by Anand & Sager.pptx
C programming introduction for beginners.pdf
Introduction to C programming
C programming Training in Ambala ! Batra Computer Centre
1. introduction to computer
PROGRAMMING IN C - SARASWATHI RAMALINGAM
BCP_u2.pptxBCP_u2.pptxBCP_u2.pptxBCP_u2.pptx
C introduction by thooyavan
C and DS -unit 1 -Artificial Intelligence and ML.docx
C lang7age programming powerpoint presentation
prateek verbal computer language 2024 .pptx
C programming presentation(final)
C PROGRAMMING LANGUAGE.pptx
history of c.ppt
C programme presentation
Programming Fundamentals and basic knowledge
C Programming Language Introduction and C Tokens.pdf
1. over view and history of c

More from Precise Mya (6)

PPTX
Unit 7 Functions.pptx
PPTX
Unit 3 Input Output.pptx
PPTX
Unit 1 Problem Solving.pptx
PPTX
Unit 6 Arrays.pptx
PPTX
Unit 5 Control Structures.pptx
PPTX
Unit 2 Communication System.pptx
Unit 7 Functions.pptx
Unit 3 Input Output.pptx
Unit 1 Problem Solving.pptx
Unit 6 Arrays.pptx
Unit 5 Control Structures.pptx
Unit 2 Communication System.pptx

Recently uploaded (20)

PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Trump Administration's workforce development strategy
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
HVAC Specification 2024 according to central public works department
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
20th Century Theater, Methods, History.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PDF
International_Financial_Reporting_Standa.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
My India Quiz Book_20210205121199924.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
What if we spent less time fighting change, and more time building what’s rig...
Hazard Identification & Risk Assessment .pdf
Chinmaya Tiranga quiz Grand Finale.pdf
Trump Administration's workforce development strategy
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
HVAC Specification 2024 according to central public works department
Weekly quiz Compilation Jan -July 25.pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
20th Century Theater, Methods, History.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
International_Financial_Reporting_Standa.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Paper A Mock Exam 9_ Attempt review.pdf.
My India Quiz Book_20210205121199924.pdf

Unit 2 Elements of C.pptx

  • 1. Dinesh Maharjan, 2022 Programming in C Elements of C Instructor: Dinesh Maharjan 2022
  • 2. • C was introduced by Brian Kernighan and Dennis Ritchie in 1978 to develop unix operating system at Bell Labs. • This version of C is known as K&R C (1972-1989). • Essentially all unix applications are written in C. • C is a successor of B language. • C is portable. • C programs are as fast as the assembly programs • C is widely used as the system programming language C Introduction
  • 3. • C has now become a widely used professional language for • Easy to learn • Structured language • Can be compiled on variety of computers. • C uses low level features such as chracters, numbers and addresses. • C operators does not work on composite data types such as strings, arrays, sets C Introduction
  • 5. • Initially, C is known as K&R C (1972-1989). • Later it was standardized by ANSI in 1989 known as ANSI- C or C89. • C was internationally accepted and was standardized by ISO in 1990 known as The C language or C90. • Minor update was released in 1995 as C95. • C99 was released in 1999 with major revision. • C11 was released in 2011 with major focus in multi- core, multi-processing and expression sequencing. C Standard
  • 6. GNU C Compiler (GCC) • For compiling C language, we need C compiler. • GNU C Compiler can be used by installing MinGW. • You should add the path of bin subdirectory of MinGW installation to PATH environmental variable.
  • 7. GNU C Compiler (GCC) • To run the executable, type a
  • 10. Tokens • Building Blocks of C language • Includes keywords, identifiers, constant, operators, special symbols
  • 16. Unary Operator ++, -- Unary Operator Binary operator +, -, *, /, % Arithmetic Operator <, <=, >, >=,==, != Relational Operator &&, !!, ! Logical Operator &, |, <<, >>, ~, ^ Bitwise Operator =, +=, -=, *=, /=, %= Assignment Operator Ternary Operator ?: Conditional Operator
  • 34. • Special Symbols that separate variables, constants or statements • (,) comma separates variables and constant • ( spacebar) separates keywords, expression • (;) semicolon separates or ends the statement. Delimiters
  • 35. • Instruction to the computer to do certain task. • Usually one statement per line. • It can span over multiple lines. • Ends with ; (Semicolon) • It is combination of keywords, expression • X=5*2; • printf(“Let C”); Statement
  • 36. • Compiler ignores white spaces in the statement. • However white spaces within a string constant is not ignored. Statement
  • 38. Types of Statement • Simple statement: x=5+9; • Null statement: ; • Compound Statement: • { • X=4+8; • Y=9+9; • }
  • 39. Expression • Combination of operand, operator and function. • Expression evaluates to some value that can be numeric or string. • 4+9 • “b”+”C”
  • 40. Comments • Make programs easy to read and modify. • Comments are removed by compiler before generating executable. • Comments is kept inside /* comment */ • It can be multiple lines also.
  • 41. Structure of a C program • Preprocessor • Comments • Function Prototype • Main function • The return type of main function must be int. • K&R C supports main() without return type. • Main without return type is defaulted int return type. • Most of compilers does not support void return type.
  • 42. #include <stdio.h> // program prints hello world int main() { printf ("Hello world!"); return 0; } Output: Hello world!

Editor's Notes