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

Lecture 01 Intro to Computer System Programming

The document provides an introduction to computer systems, focusing on basic I/O devices, conditional logic, and programming concepts, particularly the C programming language. It covers the structure and function of input and output devices, the fundamentals of binary logic operations (NOT, AND, OR), and the characteristics of structured programming. Additionally, it highlights the importance and features of C, including its history, structured programming principles, and the basic structure of a C program.

Uploaded by

uttsho131
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 01 Intro to Computer System Programming

The document provides an introduction to computer systems, focusing on basic I/O devices, conditional logic, and programming concepts, particularly the C programming language. It covers the structure and function of input and output devices, the fundamentals of binary logic operations (NOT, AND, OR), and the characteristics of structured programming. Additionally, it highlights the importance and features of C, including its history, structured programming principles, and the basic structure of a C program.

Uploaded by

uttsho131
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lecture – 01

Introduction to Computer System


Basic I/O, Conditional Logic, ASCII value, Basic concepts of Programming

Most of us know something or other about a computer. But they are limited to watching
movies and listening to music. In this course, we will be getting the basics of the units of
the computer.

A computer can have three units mainly. Each part can be divided further.

1. Memory
2. Processor
3. I/O devices

Today, our concern is to know about the I/O devices that are used to take input into the
machine and provide the outputs after processing.

Input Devices:

There are several input devices that we used. The most common and important couples are
the keyboard and mouse. The keyboard contains a lot of keys, each of which performs
various functions.

Mouse is the basic pointing input device. We all know about its operation. It is used to select
something from the screen and very handy.
There are other input devices used for special purpose like scanner, joystick, microphone,
touch pad, etc.
Output Devices:

Monitor is the most used output device along with printer, speaker, projector, etc.

The elementary structure and working principle of these devices will be covered up in
another course.

Control Logic:

It is the core of control unit which is in the processor of a computer. The control unit
manages the decision to run the operations of a computer on the basis of some inputs.

A computer can have inputs either 0 (zero) or 1 (one). We can refer an input of 0 as off
and 1 as on. Otherwise, 0 is the ground and 1 is the power, or 0 as low and 1 as high.

Now, we will take a look, how control unit takes decision according to some zeros and ones.
Normally, it receives a sequence of numbers with 2 digits only (0 and 1). So it’s a binary
number, the number system with the base of 2.

Behind the procedure of controlling, there are three fundamental conditional logic.

1. NOT
2. AND
3. OR

There are other conditional logics made from this primary three. At this moment, our
concern is to master the basics.
Let’s see one by one.

NOT:

This is a unary operation. It toggles the input. If the input bit is zero (0), it’s output will
be one (1). On the other hand, the output will be zero (0), when the input is one (1). It is
written with the symbol bar (‾).

𝐴 = ∽A = NOT A

0 = ∽0 = NOT 0 = 1

1 = ∽1 = NOT 1 = 0

AND:

It is a binary operator to control the conditional logic. It takes minimum of two bits as input
and generates a high output, if both the inputs are high that means one (1). Otherwise the
output will be zero (0) or low. The operator is written as a dot product operator (.) or using
‘&’ operator sometimes.

A.B = A & B = A AND B

1.1 = 1 & 1 = 1 AND 1 = 1

1.0 = 1 & 0 = 1 AND 0 = 0

0.1 = 0 & 1 = 0 AND 1 = 0

0.0 = 0 & 0 = 0 AND 0 = 0

OR:

It is also a binary operator. Its output is one (1), when at least a single input is one (1) or
high. The operator generates a low output, if all the inputs are zero or low. The operator is
written as a plus operator (+) or using ‘|’ operator sometimes.

A+B = A | B = A OR B
1+1 = 1 | 1 = 1 OR 1 = 1

1+0 = 1 | 0 = 1 OR 0 = 1

0+1 = 0 | 1 = 0 OR 1 = 1

0+0 = 0 | 0 = 0 OR 0 = 0

ASCII Value:

Computer stores each and every information in the form of sequence. A sequence is a set of
bits which refers to a binary number. Each binary number represents a different and
distinct character or information.

ASCII = American Standard Code for Information Interchange.


Sometimes, these values will be very useful, both in programming and theoretical work.

Data:

Data are characteristics or information, usually numerical, that are collected through
observation. In a more technical sense, data is a set of values of qualitative or quantitative
variables about one or more persons or objects, while a datum (singular of data) is a single
value of a single variable.

Information:

Information is associated with data, as data represent values attributed to parameters,


and information is data in context and with meaning attached. Organized data is called
Information.

Bit:

A bit is a binary digit, the smallest increment of data on a computer. The bit represents a
logical state with one of two possible values. It's a single unit of information that has a value
of either 0 or 1.

Byte:

A byte is a unit of digital information that most commonly consists of eight bits.

1 Byte=8 Bit
Introduction to Programming:

1. History of C

C is a general-purpose high-level language that was originally developed by Dennis Ritchie


for the UNIX operating system. It was first implemented on the Digital Equipment
Corporation PDP-11 computer in 1972.

The UNIX operating system and virtually all UNIX applications are written in the C
language. C has now become a widely used professional language for various reasons.

● Easy to learn

● Structured language

● It produces efficient programs.

● It can handle low-level activities.

● It can be compiled on a variety of computers.

● Utilities

2. Importance of C:
● C is a structured programming language
● C supports functions that enables easy maintainability of code, by breaking
large file into smaller modules
● Comments in C provides easy readability
● C is a powerful language
● Rich in built-in functions and operators that can be used to write any
complex program
● Programs written in C are efficient and fast
● C is highly portable
3. C: Characteristics
● C takes a middle path between low-level assembly language…
a. Direct access to memory layout through pointer manipulation
b. Concise syntax, small set of keywords
● A high-level programming language like Java:
c. Block structure
d. Some encapsulation of code, via functions
e. Type checking (pretty weak)
Structured Programming

� There are three main principles of structured programming:


1. Program Design using top-down or bottom-up approach.
2. Decomposition of program into components
3. Structuring of control flow

Main Features of Structured Programming Language

1. Division of Complex problems into small procedures and functions.


2. No presence of GOTO Statement
3. The main statement includes – If-then-else, Call and Case statements.
4. Large set of operators like arithmetic, relational, logical, bit manipulation, shift and
part word operators.
5. Inclusion of facilities for implementing entry points and external references in the
program.

Unstructured Programming Language

� A programming language in which the entire logic of the program is written as a single
continuous (nonstop or unbroken) block is called "unstructured Programming".
� Program written by following this language is very difficult to modify and to debug

Why C language is Structured Language?

� In order to accomplish any task, C-language divide the problem into smaller modules
called functions or procedure each of which handles a particular job. That is why C-
language is also called as the structured programming language. The program which
solves the entire problem is a collection of such functions.
� In C Programming when writing a program we add preprocessor directive
#inclue<filename>, than functions like main(), then opening of braces { }, inside the
braces there are two parts declaration of variables and execution of statements
which is a step by step process and well structured so anyone in the first look can
understand what codes are doing what in which section.
� The structured programming languages allow the program to be splied into multiple
blocks of execution.
� In C, you can split the program into such named blocks called functions.

That is why it is called a structured programming language


Features of C Language

C is the widely used language. It provides many features that are given below.

1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible

Structured Vs. Unstructured

Comparison between Structured and Unstructured Programming Language:

Properties Unstructured Programming


Structured Programming Language
Language

Also known as Modular Programming Non-structured Programming

To enforce a logical structure on


the program being written to make
Purpose Just to code.
it more efficient and easier to
understand and modify.

Divides the program into smaller The entire program must be coded
Programming
units or modules. in one continuous block.

Offers freedom to programmers


Freedom Has some limitations
to program as they want
Non-structured languages allow
only basic data types, such as
Structured languages allow a
Allowed data types numbers, strings and arrays
variety of data types.
(numbered sets of variables of
the same type).

Very difficult to modify and to


Modify and debug Easy to modify and to debug
debug

early versions of BASIC (such as


MSX BASIC and GW-BASIC),
JOSS, FOCAL, MUMPS,
TELCOMP, COBOL, machine-level
C, C+, C++, C#, Java, PERL, Ruby, code, early assembler systems
Languages
PHP, ALGOL, Pascal, PL/I and Ada (without procedural
metaoperators), assembler
debuggers and some scripting
languages such as MS-DOS batch
file language.

4. Program in C

C program basically has the following form:

● Preprocessor Commands

● Functions

● Variables

● Statements & Expressions

● Comments
The following program is written in the C programming language. Open a text
file hello.c using vi editor and put the following lines inside that file.

#include <stdio.h>
int main()
{
printf("Hello, World! \n");
/* My first program */
return 0;
}

Preprocessor Commands: These commands tell the compiler to do preprocessing before


doing actual compilation. Like #include <stdio.h>is a preprocessor command which tells a C
compiler to include stdio.h file before going to the actual compilation. You will learn more
about C Preprocessors in C Preprocessors session.

Functions: are the main building blocks of any C Program. Every C Program will have one or
more functions and there is one mandatory function which is called main () function. This
function is prefixed with keyword int which means this function returns an integer value
when it exits. This integer value is returned using return statement.

The C Programming language provides a set of built-in functions. In the above


example, printf() is a C built-in function that is used to print anything on the screen.
Check Builtin function section for more detail.

You will learn how to write your own functions and use them in Using Function session.

Variables: are used to hold numbers, strings and complex data for manipulation. You will
learn in detail about variables in C Variable Types.

Statements & Expressions: Expressions combine variables and constants to create new
values. Statements are expressions, assignments, function calls, or control flow statements
which make up C programs.

Comments: are used to give additional useful information inside a C Program. All the
comments will be put inside /*...*/ as given in the example above. A comment can span
through multiple lines.

You might also like