0% found this document useful (0 votes)
3 views

2025 Basic Computer Programming Week01 Part2

The document provides an introduction to basic computer programming, covering essential components of a computer such as the CPU, memory, input/output devices, and types of software. It explains the concepts of algorithms and flowcharts, illustrating their importance in programming. Additionally, it offers an overview of the C programming language, its history, structure, and execution process across different systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

2025 Basic Computer Programming Week01 Part2

The document provides an introduction to basic computer programming, covering essential components of a computer such as the CPU, memory, input/output devices, and types of software. It explains the concepts of algorithms and flowcharts, illustrating their importance in programming. Additionally, it offers an overview of the C programming language, its history, structure, and execution process across different systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

기초 컴퓨터 프로그래밍

(Basic Computer
Programming)

1
Chapter 1
Introduction to Computing
Components of a Computer
• Computer
– Electronic device which may be uses to perform various computations
involving arithmetic and logical operations.

Fig. 1.1 Components of A Computer


Components of a Computer:
Central Processing Unit
• CPU
– Very large scale integrated (VLSI) electronic circuit that consists of the
arithmetic and logic unit (ALU), the control unit (CU) and some
registers.

Fig. 1.2 Layout of a Model CPU


Components of a Computer:
Input Devices/Output Devices
• Input devices
– Users are allowed to input data and other instructions to the
computer.
• Keyboard and Mouse
– The most popular input devices

• Output devices
– Computer to convey messages back to the users.
• Monitor
– The most common output device
Components of a Computer:
Memory
• The memory is broadly classified into primary memory and
secondary memory.

• Primary (main) memory


– CPU can directly interact with it through the data bus and the address
bus.
• Random access memory (RAM)
– Volatile memory that stores instructions and data
• Read only memory (ROM)
– Non-volatile memory

• Secondary memory
– Hard disk, flash drives, etc.
Components of a Computer:
Memory

Fig. 1.3 Classification of Computer’s Memory


Concept of Hardware and Software:
Types of Software
• System Software
– Interaction with the hardware of a computer
– Controlling the resources of the system and perform other activities
related to the system.
– Operating system, loader, linker and translator

• Operating System
– Linux, Windows, UNIX, macOS etc.

• Translators
– Translating a program written in high level language (HLL) into
machine language.
– HLL : C, C++, Java, etc.
Concept of Hardware and Software:
Types of Software
• Linker
– Linking together the object codes belonging to all the sub-
routines/functions of a program and forms an executables code.

• Loader
– Loading a program to be executed from the secondary memory into a
designated area of the main memory.

• Application Software
– Word processing, image editing, spread sheet, database software, etc.
Art of Programming through
Algorithms and Flowcharts:
Algorithms
Algorithm:
Algorithm to find Average of Three Numbers
• Algorithm
– Finite set of unambiguous instructions witch, when executed,
performs a task correctly.
Algorithm:
Algorithm to find Average of Three Numbers
• Algorithm
– Finite set of unambiguous instructions witch, when executed,
performs a task correctly.

Fig. 1.4 Algorithm to find Average of Three Numbers


Algorithm:
Algorithm for Division and Finding Quotient

Fig. 1.5 Algorithm for Division and Finding Quotient


Algorithm:
Algorithm to find Maximum of Two Numbers
Algorithm:
Algorithm to find Maximum of Two Numbers

Fig. 1.6 Algorithm to find Maximum of Two Numbers


Flowchart:
Notations Used in a Flowchart
• Flowchart
– Helps us graphically visualize the flow of control within the sequence
of statements.

Fig. 1.7 Notations Used in a Flowchart


Flowchart:
Flowchart to find Average of Three Numbers

Fig. 1.8 Flowchart to find Average of Three Numbers


Flowchart:
Flowchart for Division and Finding Quotient

Fig. 1.9 Flowchart for Division and Finding Quotient


Flowchart:
Flowchart to find Maximum of Two Numbers

Fig. 1.10 Flowchart to find Maximum of Two Numbers


Flowchart: Algorithm and Flowchart to find Sum of Even numbers
out of N numbers

Fig. 1.11 Algorithm and Flowchart to find Sum of Even numbers out of N numbers
Flowchart : Program to find Sum of Even numbers out of N
numbers

Fig. 1.12 Program to find Sum of Even numbers out of N numbers


KEY CONCEPTS
• HARDWARE: The major Hardware components of a computer are
the CPU, primary memory and input and output Devices.

• SOFTWARE: Two types of software are system and application


software.

• ALGORITHM: An algorithm uses English-like statements to show the


flow of logic in a step-wise manner.

• FLOWCHART: Flowchart is a graphical tool to represent logic flow.


ALWAYS REMEMBER
• The central processing unit is a VLSI circuit.
• The control unit generates control signals and send them to the
different components of a computer.
• The arithmetic logic unit has many circuits inside it that are capable
of performing various arithmetic and logic operations.
• Input device are used by the user to feed data and other
information to the computer.
• Output devices are used by the computer to display an output or
give the result of an operation to the user.
• Memory is of two types – the primary and the secondary memory.
• The CPU has direct connections to the primary memory.
• The RAM is a volatile memory.
ALWAYS REMEMBER
• The ROM is a non-volatile memory.
• The secondary memory services as a data reservoir.
• System software are those which interact with the hardware of the
computer.
• The operating system acts as an interface between the user and
the hardware.
• It is not possible to execute a program written in a high level
language of assembly language directly without first translation.
• A high level languages uses a compiler for translation.
• A compiler is always typical of a programming language.
• Before writing a program, the algorithm and/or the flowchart for
the same should be developed.
ALWAYS REMEMBER
• Algorithms and flowcharts should be independent of programming
languages.
• The three main programming constructs are imperative,
conditional and iterative statements.
• Algorithms do not have a fixed style of writing.
• Algorithms should be finite and current and the statements in it
should be unambiguous.
• Flowcharts give us a visual depiction of logic flow.
Chapter 2
Overview of C
History of C:
History of ANSI C

Fig. 2.1 History of ANSI C


Importance of C
• C is a structured, high-level, machine independent language.
• ANSI C and C99 are the standardized versions of C language.
• C combines the capabilities of assembly language with the features
of a high level language.
• C is robust, portable and structured programming language.
Program

29
A Simple Program 1:
Printing a Message

Fig. 2.2 A program to print one line of text

• Output:
I see, I remeber
Sample Program 1:
Printing a Message

Fig. 2.3 Format of simple C programs


Sample Program 2:
Adding Two Numbers

Fig. 2.4 Program to add two numbers

• Output:
100
106.10
Sample Program 3:
Interest Calculation

Fig. 2.5 Program for investment problem


Sample Program 3:
Interest Calculation

Fig. 2.6 Output of the investment program


Sample Program 4:
Use of Subroutines

Fig. 2.7 A program using a user-defined function


Sample Program 5:
Use of MATH Functions

Fig. 2.8 Program using a math function


Basic Structure of C Programs

Fig. 2.9 An overview of a C program


Programming Style
• C is free-form language.
a = b;
x = y + 1;
z = a + x;
• Can be written on one line as
a = b; x = y + 1; z = a + x;
Executing a ‘C’ Program

Fig. 2.10 Process of compiling and running a C program


Unix System:
• Creating the Program
– Program must be entered into a file.
– Examples of valid file names are:
hello.c
program.c
ebg1.c
– File is created with the help of a text editor, either ed or vi.
ed filename
• Compiling and Linking
– UNIX compilation command
cc ebg1.c
– Compiled and linked program is called executable object code and it stored
automatically in another file named a.out.
– Compilation command for linking mathematical functions.
cc filename -lm
Unix System:
• Executing the Program
– Execution is a simple task. The command
a.out
• Creating Your Own Executable File
– cc command as follows:
cc –o name source-file
Unix System:
Creating the Program
• Multiple Source Files
– cc command:
cc filename-1.c … filename-n.c
– These files will be separately compiled into object files called
filename-1.o … filename-n.o

Fig. 2.11 Compilation of multiple files


MS-DOS System
• Compilation command:
MSC pay.c
• Linking command:
LINK pay.obj
• Executing command:
pay.exe

43
Windows System
• There are several IDEs.
– Borland C/C++
– Microsoft Visual Studio
– Dev-C++
– Turbo C/C++
– etc.

44
KEY CONCEPTS
• #define: Is a preprocessor compiler directive.

• printf: Is a predefined standard C function that writes the output to


the stdout (standard output) stream.

• scanf: Is a predefined standard C function that reads formatted


input from stdin (standard input) stream.

• PROGRAM: Is a sequence of instructions written to perform a


specific task in the computer.
ALWAYS REMEMBER
• C is a structured, high-level, machine independent language.
• ANSI C and C99 are the standardized versions of C language.
• C combines the capabilities of assembly language with the features
of a high-level language.
• C is robust, portable and structured programming language.
• Every C program requires a main() function (Use of more than one
main() is illegal). The place main is where the program execution
begin.
• The execution of a function begins at the opening brace of the
function and ends at the corresponding closing brace.
• C programs are written in lowercase letters. However, uppercase
letters are used for symbolic names and output strings.

You might also like