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
durk computer,computer clan,jim's computer,chama computer,computer gk for,tiktok computer,gaming computer,kvs computer science full syllabus,chama computers,lil durk computer,trucchi computer,bhuture computer,computer science,patwari computer,computer security,computer for uppcl,
computer business basic computer
Characteristics of C language
Basic Program Structure in C
Language
4.16.24 21st Century Movements for Black Lives.pptx
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
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
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
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
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
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