SlideShare a Scribd company logo
Overview
 Introduction to Computer
 Program and Programming Languages
 Types of Programming Languages
 Low-Level Languages
 Assembly languages
 High-Level Languages
 History of Programming Languages
 Translators
 Compiler
 Interpreter
 Typical C Program Development Environment
 The C Programming Language
 Characteristics of C language
 Basic Program Structure in C Language
1
Introduction
 Computer
A computer is an electronic device which is capable to
• receive the data,
• process the data, and
• provide results
according to a set of instructions
 Program
A program is a set of instructions of a computer language, where each
instruction tells the computer to do something:
For example,
• get two numbers as input,
• add these numbers,
• print the sum as output
2
Programming Languages
 Programming Language
 A programming language defines the rules for writing instructions
 Programmers write instructions in a programming language
 Types of Programming Languages
A number of programming languages are in use today and are
generally categorized as follows:
 Low-Level Languages
 Assembly languages
 High-Level Languages
3
Types of Languages
 Low-Level language or Machine/Binary Language
 This language consists of binary numbers to perform a task
 Machine language is directly understandable to the computer
 Machine languages are machine dependent (i.e., a particular machine
language can be used on only one type of computer)
 Programming in machine-language is very slow, tiresome and error prone
for the programmers
4
Types of Languages
 Assembly language
 It was developed to overcome the problems with machine language
 Assembly language uses English-like abbreviations to programming, such as
ADD for adding numbers
 As the assembly language is not the machine own’s language, so translators
were developed called assemblers
 Assemblers translate the assembly-language programs into the machine
language programs
5
Types of Languages
 High level language
 In early programming languages, the programmers had to write many
instructions to perform a single task
 The high-level languages use a single instruction to perform many tasks
 Compilers or interpreters are used as translators to convert high-level
language programs into machine language
 C, C++, Visual Basic, Visual C++, Visual C#, Python and Java are the most
commonly used high-level programming languages today
6
Types of translators
 Compiler
 Interpreter
7
Translators and Types
 Translator
 A translator is used convert a high level language program
(source code) into machine language (object code)
Source code object code
 Types of translators
 Compiler
 Interpreter
8
Compiler vs. Interpreter
 Compiler
 A compiler first reads the whole source code, and converts
it into a its equivalent machine language, if there are no
errors(bugs)
 Reports a list of errors, if errors in the source code
 Faster translation
 C, C++, C# etc. are the examples of compiled languages
9
Compiler vs. Interpreter
 Interpreter
 An interpreter performs line by line translation
 It first reads the first line of the source code, and converts it into a its
equivalent machine code (if no error), then the second line, and so on
 If there is error, it reports it and the user has to correct it, and after this,
the source code to object code translation occurs
 Slower translation than compiler
 Java, Python etc. are called interpreted languages
10
Why study programming Languages?
 In 1967, Sammet, an American computer scientist and one of the
developers of the COBOL programming language, reported 120
programming languages commonly used
 Today , these languages are many more
 Most programmers never use more than a few, some limit their
career to just on or two
 The goal in learning about a language is its fundamental design
concepts and how this affects its implementation
11
12
https://www.tiobe.com/tiobe-index/
Programming Languages Popularity
Programming Domains
 Scientific applications(Fortran)
 Business Applications(COBOL)
 Artificial Intelligence(LISP, Prolog)
 System Programming(C )
 Web software (HTML, PHP, Java)
 General Purpose (Python)
13
14
The Ideal Way to Do Computing
 The ideal way to ask computer to do something is to order it in a
natural language e.g.
 I want to view this webpage
 Calculate my annual tax
 etc.
 However, today’s computer’s are not intelligent enough to
understand our orders in natural language
15
Where We Are in Computers?
 At the very basic level, computers use the concept of an electrical pulse
 Low voltage is represented as 0
 High voltage is represented as 1
 To instruct a computer, we need ask the computer in the language of 0s and
1s commonly known as machine language
 For example, 5 is a number in natural language, so in the language of
0s and 1s, it becomes 101
 In Today’s computing, we use a high-level language to instruct the
computer
 The compiler translates these instructions into the machine language
16
Where are we going?
 The next step in computing is to use natural language over a high-level
language
 But we are many more years away from it
 A lot of research needs to be carried out before we actually see this
 Until then our task is to use high-level languages in its best possible
ways
Program & Its Various Aspects
17
18
What is Programming?
 When we say “programming” we are actually referring
to the science of transforming our intentions in a
high-level programming language
19
Many Aspects of Programming
 Programming is controlling
 computer does exactly what you tell it to do
 Programming is teaching
 computer can only “learn” to do new things if you tell it how
 Programming is problem solving
 always trying to make computer do something useful — i.e., finding
an optimal travel route
 Programming is creative
 must find a good solution out of many possibilities
20
Many Aspects of Programming
 Programming is modelling
 describe salient (relevant) properties and behaviours of a system
of components (objects)
 Programming is abstraction
 identify important features without getting lost in detail
 Programming is concrete
 must provide detailed instructions to complete task
C-Language
 History & characteristics of C language
21
History of C language
 C language was developed by Dennis Ritchie and Ken Thompson in
1972 at Bell Labs where they were working on Unix Operating System
 Dennis Ritchie is known as the founder of the C language
 C was developed to add additional features to its earlier
languages such as B, BCPL, etc.
 It inherits many features of B and BCPL languages
22
Characteristics of C language
1. C is a General Purpose Programming Language
- This means that C language can be used to write a variety of
applications
2. C is a structured programming language
- This means that when you program in C language, a problem is
divided into several small units called functions
3. C is a simple language
- This means that C language is easy to use and has a vast
collection of keywords, operators, built-in functions and data
types
23
Characteristics of C language
4. C is case sensitive language
- This means that in C language the lower case letters are
different from upper case letters
5. C is portable language
-This means that a program written in C language can be run on
different hardware platforms
24
Characteristics of C language
6.C is a flexible language
-This means that C language can be used like a high level
language and like a low level language
7. C is easily available language
-The C software is easy to access and can be easily installed
on a user computer within a few minutes
25
Characteristics of C language
8. C is easily debugged language
 The C is easy to debug
 The C compiler detects syntax errors quickly and easily and
displays the errors along with the line numbers of the code and
the error message
9. C has a number of in-built memory management functions that save
memory and improve the efficiency of the program
10. C has a rich set of library functions for various arithmetic and
trigonometric calculations
26
C-Program Development Environment
(IDE)
27
C IDE
 A C program development environment is called IDE(Integrated
Development Environment)
 Many IDEs available today and some are as follows
 DEVCpp
 Microsoft Visual Studio
 Eclipse
 NetBeans
 Code::Blocks
 etc.
 We use DEVCpp, for C program development in this course
28
C Program Execution Phases
 C program goes through six phases to be executed. These
are as follows:
 Edit
 Preprocess
 Compile
 Link
 Load
 Execute
29
C Program Execution Phases
30
C Program Execution Phases
31
Execution Phases
 Phase 1: Editing/Creating a Program
 Phase 1 consists of editing a file
 To edit a file, we use Dev C++ IDE
 A C program is typed or coded in the IDE
 After coding, the program is stored on a hard disk
 A C program file name should end with the .c extension
 Phases 2 : Preprocessing the Program
 In C language, a preprocessor program is executed automatically
before compilation begins
 Here the C preprocessor calls the preprocessor directives(e.g.
#include<…>)
32
Execution Phases
 Phases 3 : Compiling the Program
 The compiler translates the c program code called source code into
machine language-code called object code
 The compiler translates the C program into machine-language code
 To compile the program, we use the compile command in the IDE
 Phase 4: Linking
 A linker links the object code for the missing functions to produce an
executable image
33
Execution Phases
 Phase 5: Loading
 Before a program can be executed, the program must first be placed in
memory
 This is done by the loader, which takes the executable image from disk
and transfers it to memory
 Additional components from shared libraries that support the program
are also loaded
 Phase 6: Execution
 Finally, the computer, under the control of its CPU, executes the
program one instruction at a time
 To load and execute the program, we run the program in the IDE
34
Basic Program Structure in C
35
Basic Program Structure in C Language
36
#include<stdio.h>
int main()
{
// program statement_1;
// program statement_2
…
return 0;
}
Writing Program in C using DEVCpp IDE
37
Steps to follow:
1. Click on File
2. Select New, and
3. Click on Source File
4. Start coding in the source file(in the figure, sample example)
5. Save it with a name(e.g., first.c)
6. Compile, and
7. Run
Writing Program in C using DEVCpp IDE
38
Sample
Program
C Program Example
#include<stdio.h>
int main()
{
printf("Welcome to C language");
return 0;
}
39
Program output:
Welcome to C language
Example: A simple C Program
#include<stdio.h>
int main()
{
printf("Welcome Studentsn");
Printf(“This is C language statement”);
return 0;
}
40
Program output:
Welcome Students
This is C language statement
Escape Sequence in C
41
Escape sequence
 Escape sequence is a set of characters followed by backslash (),
which has a particular meaning for the compiler to do something
with the output statement
 For example, the escape sequence n means newline, which causes
the cursor to position to the beginning of the next line on the
screen
 C language supports the following escape sequences
42
Escape sequence
43
b for backspace, remove one character at the back
’ single quote, insert a single-quote character in a string
Escape Sequence Example
#include<stdio.h>
int main()
{
printf(“This isn C language statement n”);
printf(“Thist ist Ct languaget statement n”);
printf(“ Thisa isa Ca languagea statement n”);
printf(“ ab n”);
printf(“ This is ”C language” statement n”);
printf(“ ’A’ for Apple n”);
printf(“ Hib n”);
return 0;
}
44
Escape Sequence Example…
45
Program output:
This is
C language statement
This is C language statement
This (alert) is (alert) C (alert) language (alert) statement
ab
This is ”C language” statement
‘A’ for Apple
H
Program Comments in C
46
Comments
 Comments are used to document a program:
 Improve program readability and help other people read and understand
your program
 Dot cause the computer to perform any action when the program is run
 Ignored by the C compiler and do not cause any machine-language object
code to be generated
 Types of Comments:
 Single-line comments e.g. //This is first C program
 Multi-line comments e.g. /* This is first C program
Author: Ali
Dated: October 20, 2020 */
47
Example: Comments
// A first program in C
/* Author: Ali
Dated: October 05, 2020
*/
#include<stdio.h>
int main()
{
printf(“This is C language statement”);
return 0;
}
48
Program output:
This is C language statement

More Related Content

PPTX
Computer Language Translator
PPT
Intro To Programming Concepts
PPTX
System Programming- Unit I
PPT
basics of compiler design
PPT
Generations of Programming Languages
PPT
Lecture 5 - Structured Programming Language
PPT
Compiler Design
PPTX
Programming languages
Computer Language Translator
Intro To Programming Concepts
System Programming- Unit I
basics of compiler design
Generations of Programming Languages
Lecture 5 - Structured Programming Language
Compiler Design
Programming languages

What's hot (20)

PDF
Introduction to c++ ppt 1
PPT
Introduction to qbasic
PPTX
Basic Computer Programming
ODP
Introduction to Python - Training for Kids
PPT
Lecture 1- History of C Programming
PDF
Algorithm and Programming (Introduction of Algorithms)
PPSX
Programming Fundamental Presentation
PPTX
Introduction to C# Programming
PPTX
Programming Fundamental Slide No.1
PPTX
Procedural programming
PPTX
1. importance of c
PPTX
Introduction to problem solving in C
PPTX
Classification of Programming Languages
PPTX
Introduction to loaders
PPTX
Programming Fundamentals lecture 1
PPTX
Types of Programming Languages
PPTX
Translators(Compiler, Assembler) and interpreter
PPTX
Introduction to C programming
PPT
Program design and problem solving techniques
PPT
Programming languages
Introduction to c++ ppt 1
Introduction to qbasic
Basic Computer Programming
Introduction to Python - Training for Kids
Lecture 1- History of C Programming
Algorithm and Programming (Introduction of Algorithms)
Programming Fundamental Presentation
Introduction to C# Programming
Programming Fundamental Slide No.1
Procedural programming
1. importance of c
Introduction to problem solving in C
Classification of Programming Languages
Introduction to loaders
Programming Fundamentals lecture 1
Types of Programming Languages
Translators(Compiler, Assembler) and interpreter
Introduction to C programming
Program design and problem solving techniques
Programming languages
Ad

Similar to Introduction to Computer (20)

PPTX
L1.1 Introduction to Programming Languages.pptx
PPTX
Programming in C & Decision Making Branching
PPTX
Programming in C and Decision Making Branching
PDF
PPTX
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
PPTX
PRESENTATION OF students learning outcomes.pptx
PPTX
Introduction to Programming Concepts By Aamir Saleem Ansari
PPTX
Define Computer language, Translator, Standard input out C
PPTX
Introduction to c language
PPT
Fundamentals of Programming Chapter 2
PPTX
C Programming Lab_Program_Presentation__a
PPTX
lecture Slides - Week 1.programming fundamentals
PDF
sege.pdf
PDF
Introduction to computer programming
PDF
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy1.pdf
PPTX
programming.pptx
PPTX
Programming in c
PPTX
Programming in C
L1.1 Introduction to Programming Languages.pptx
Programming in C & Decision Making Branching
Programming in C and Decision Making Branching
UNIT - 1jhjhjbkjhkjhkjhkjhkjhhkkhhh.pptx
PRESENTATION OF students learning outcomes.pptx
Introduction to Programming Concepts By Aamir Saleem Ansari
Define Computer language, Translator, Standard input out C
Introduction to c language
Fundamentals of Programming Chapter 2
C Programming Lab_Program_Presentation__a
lecture Slides - Week 1.programming fundamentals
sege.pdf
Introduction to computer programming
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy1.pdf
programming.pptx
Programming in c
Programming in C
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Classroom Observation Tools for Teachers
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Classroom Observation Tools for Teachers
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Weekly quiz Compilation Jan -July 25.pdf
Chinmaya Tiranga quiz Grand Finale.pdf
human mycosis Human fungal infections are called human mycosis..pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
A systematic review of self-coping strategies used by university students to ...
O7-L3 Supply Chain Operations - ICLT Program
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
STATICS OF THE RIGID BODIES Hibbelers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Supply Chain Operations Speaking Notes -ICLT Program
VCE English Exam - Section C Student Revision Booklet

Introduction to Computer

  • 1. Overview  Introduction to Computer  Program and Programming Languages  Types of Programming Languages  Low-Level Languages  Assembly languages  High-Level Languages  History of Programming Languages  Translators  Compiler  Interpreter  Typical C Program Development Environment  The C Programming Language  Characteristics of C language  Basic Program Structure in C Language 1
  • 2. Introduction  Computer A computer is an electronic device which is capable to • receive the data, • process the data, and • provide results according to a set of instructions  Program A program is a set of instructions of a computer language, where each instruction tells the computer to do something: For example, • get two numbers as input, • add these numbers, • print the sum as output 2
  • 3. Programming Languages  Programming Language  A programming language defines the rules for writing instructions  Programmers write instructions in a programming language  Types of Programming Languages A number of programming languages are in use today and are generally categorized as follows:  Low-Level Languages  Assembly languages  High-Level Languages 3
  • 4. Types of Languages  Low-Level language or Machine/Binary Language  This language consists of binary numbers to perform a task  Machine language is directly understandable to the computer  Machine languages are machine dependent (i.e., a particular machine language can be used on only one type of computer)  Programming in machine-language is very slow, tiresome and error prone for the programmers 4
  • 5. Types of Languages  Assembly language  It was developed to overcome the problems with machine language  Assembly language uses English-like abbreviations to programming, such as ADD for adding numbers  As the assembly language is not the machine own’s language, so translators were developed called assemblers  Assemblers translate the assembly-language programs into the machine language programs 5
  • 6. Types of Languages  High level language  In early programming languages, the programmers had to write many instructions to perform a single task  The high-level languages use a single instruction to perform many tasks  Compilers or interpreters are used as translators to convert high-level language programs into machine language  C, C++, Visual Basic, Visual C++, Visual C#, Python and Java are the most commonly used high-level programming languages today 6
  • 7. Types of translators  Compiler  Interpreter 7
  • 8. Translators and Types  Translator  A translator is used convert a high level language program (source code) into machine language (object code) Source code object code  Types of translators  Compiler  Interpreter 8
  • 9. Compiler vs. Interpreter  Compiler  A compiler first reads the whole source code, and converts it into a its equivalent machine language, if there are no errors(bugs)  Reports a list of errors, if errors in the source code  Faster translation  C, C++, C# etc. are the examples of compiled languages 9
  • 10. Compiler vs. Interpreter  Interpreter  An interpreter performs line by line translation  It first reads the first line of the source code, and converts it into a its equivalent machine code (if no error), then the second line, and so on  If there is error, it reports it and the user has to correct it, and after this, the source code to object code translation occurs  Slower translation than compiler  Java, Python etc. are called interpreted languages 10
  • 11. Why study programming Languages?  In 1967, Sammet, an American computer scientist and one of the developers of the COBOL programming language, reported 120 programming languages commonly used  Today , these languages are many more  Most programmers never use more than a few, some limit their career to just on or two  The goal in learning about a language is its fundamental design concepts and how this affects its implementation 11
  • 13. Programming Domains  Scientific applications(Fortran)  Business Applications(COBOL)  Artificial Intelligence(LISP, Prolog)  System Programming(C )  Web software (HTML, PHP, Java)  General Purpose (Python) 13
  • 14. 14 The Ideal Way to Do Computing  The ideal way to ask computer to do something is to order it in a natural language e.g.  I want to view this webpage  Calculate my annual tax  etc.  However, today’s computer’s are not intelligent enough to understand our orders in natural language
  • 15. 15 Where We Are in Computers?  At the very basic level, computers use the concept of an electrical pulse  Low voltage is represented as 0  High voltage is represented as 1  To instruct a computer, we need ask the computer in the language of 0s and 1s commonly known as machine language  For example, 5 is a number in natural language, so in the language of 0s and 1s, it becomes 101  In Today’s computing, we use a high-level language to instruct the computer  The compiler translates these instructions into the machine language
  • 16. 16 Where are we going?  The next step in computing is to use natural language over a high-level language  But we are many more years away from it  A lot of research needs to be carried out before we actually see this  Until then our task is to use high-level languages in its best possible ways
  • 17. Program & Its Various Aspects 17
  • 18. 18 What is Programming?  When we say “programming” we are actually referring to the science of transforming our intentions in a high-level programming language
  • 19. 19 Many Aspects of Programming  Programming is controlling  computer does exactly what you tell it to do  Programming is teaching  computer can only “learn” to do new things if you tell it how  Programming is problem solving  always trying to make computer do something useful — i.e., finding an optimal travel route  Programming is creative  must find a good solution out of many possibilities
  • 20. 20 Many Aspects of Programming  Programming is modelling  describe salient (relevant) properties and behaviours of a system of components (objects)  Programming is abstraction  identify important features without getting lost in detail  Programming is concrete  must provide detailed instructions to complete task
  • 21. C-Language  History & characteristics of C language 21
  • 22. History of C language  C language was developed by Dennis Ritchie and Ken Thompson in 1972 at Bell Labs where they were working on Unix Operating System  Dennis Ritchie is known as the founder of the C language  C was developed to add additional features to its earlier languages such as B, BCPL, etc.  It inherits many features of B and BCPL languages 22
  • 23. Characteristics of C language 1. C is a General Purpose Programming Language - This means that C language can be used to write a variety of applications 2. C is a structured programming language - This means that when you program in C language, a problem is divided into several small units called functions 3. C is a simple language - This means that C language is easy to use and has a vast collection of keywords, operators, built-in functions and data types 23
  • 24. Characteristics of C language 4. C is case sensitive language - This means that in C language the lower case letters are different from upper case letters 5. C is portable language -This means that a program written in C language can be run on different hardware platforms 24
  • 25. Characteristics of C language 6.C is a flexible language -This means that C language can be used like a high level language and like a low level language 7. C is easily available language -The C software is easy to access and can be easily installed on a user computer within a few minutes 25
  • 26. Characteristics of C language 8. C is easily debugged language  The C is easy to debug  The C compiler detects syntax errors quickly and easily and displays the errors along with the line numbers of the code and the error message 9. C has a number of in-built memory management functions that save memory and improve the efficiency of the program 10. C has a rich set of library functions for various arithmetic and trigonometric calculations 26
  • 28. C IDE  A C program development environment is called IDE(Integrated Development Environment)  Many IDEs available today and some are as follows  DEVCpp  Microsoft Visual Studio  Eclipse  NetBeans  Code::Blocks  etc.  We use DEVCpp, for C program development in this course 28
  • 29. C Program Execution Phases  C program goes through six phases to be executed. These are as follows:  Edit  Preprocess  Compile  Link  Load  Execute 29
  • 30. C Program Execution Phases 30
  • 31. C Program Execution Phases 31
  • 32. Execution Phases  Phase 1: Editing/Creating a Program  Phase 1 consists of editing a file  To edit a file, we use Dev C++ IDE  A C program is typed or coded in the IDE  After coding, the program is stored on a hard disk  A C program file name should end with the .c extension  Phases 2 : Preprocessing the Program  In C language, a preprocessor program is executed automatically before compilation begins  Here the C preprocessor calls the preprocessor directives(e.g. #include<…>) 32
  • 33. Execution Phases  Phases 3 : Compiling the Program  The compiler translates the c program code called source code into machine language-code called object code  The compiler translates the C program into machine-language code  To compile the program, we use the compile command in the IDE  Phase 4: Linking  A linker links the object code for the missing functions to produce an executable image 33
  • 34. Execution Phases  Phase 5: Loading  Before a program can be executed, the program must first be placed in memory  This is done by the loader, which takes the executable image from disk and transfers it to memory  Additional components from shared libraries that support the program are also loaded  Phase 6: Execution  Finally, the computer, under the control of its CPU, executes the program one instruction at a time  To load and execute the program, we run the program in the IDE 34
  • 36. Basic Program Structure in C Language 36 #include<stdio.h> int main() { // program statement_1; // program statement_2 … return 0; }
  • 37. Writing Program in C using DEVCpp IDE 37 Steps to follow: 1. Click on File 2. Select New, and 3. Click on Source File 4. Start coding in the source file(in the figure, sample example) 5. Save it with a name(e.g., first.c) 6. Compile, and 7. Run
  • 38. Writing Program in C using DEVCpp IDE 38 Sample Program
  • 39. C Program Example #include<stdio.h> int main() { printf("Welcome to C language"); return 0; } 39 Program output: Welcome to C language
  • 40. Example: A simple C Program #include<stdio.h> int main() { printf("Welcome Studentsn"); Printf(“This is C language statement”); return 0; } 40 Program output: Welcome Students This is C language statement
  • 42. Escape sequence  Escape sequence is a set of characters followed by backslash (), which has a particular meaning for the compiler to do something with the output statement  For example, the escape sequence n means newline, which causes the cursor to position to the beginning of the next line on the screen  C language supports the following escape sequences 42
  • 43. Escape sequence 43 b for backspace, remove one character at the back ’ single quote, insert a single-quote character in a string
  • 44. Escape Sequence Example #include<stdio.h> int main() { printf(“This isn C language statement n”); printf(“Thist ist Ct languaget statement n”); printf(“ Thisa isa Ca languagea statement n”); printf(“ ab n”); printf(“ This is ”C language” statement n”); printf(“ ’A’ for Apple n”); printf(“ Hib n”); return 0; } 44
  • 45. Escape Sequence Example… 45 Program output: This is C language statement This is C language statement This (alert) is (alert) C (alert) language (alert) statement ab This is ”C language” statement ‘A’ for Apple H
  • 47. Comments  Comments are used to document a program:  Improve program readability and help other people read and understand your program  Dot cause the computer to perform any action when the program is run  Ignored by the C compiler and do not cause any machine-language object code to be generated  Types of Comments:  Single-line comments e.g. //This is first C program  Multi-line comments e.g. /* This is first C program Author: Ali Dated: October 20, 2020 */ 47
  • 48. Example: Comments // A first program in C /* Author: Ali Dated: October 05, 2020 */ #include<stdio.h> int main() { printf(“This is C language statement”); return 0; } 48 Program output: This is C language statement