Professional Documents
Culture Documents
PC Unit 1 GVK
PC Unit 1 GVK
Vijaya Kumar G
Assistant Professor
Department of ECE
VNRVJIET
Instructions
2. Input devices
3. Output devices
Memory Unit
Control Unit
CPU
( Central Processing Unit )
CU (Control Unit)
ALU
ALU (Arithmetic Logic Unit)
MU (Memory Unit)
Memory Unit
Keyboard Monitor
Mouse Printer
CD/DVD writer Speaker
Microphone Projector
Camera
Joystick
Scanner
Hardware is a physical parts of computer that cause Software is a set of instructions that tells a
processing of data. computer exactly what to do.
As Hardware are physical electronic devices, we can We can see and also use the software but can’t
see and touch hardware. actually touch them.
It has four main categories: input device, output It is mainly divided into System software,
devices, storage, and internal components. Programming software and Application software.
Ex: Keyboard, Mouse, Monitor, Printer, CPU, Hard Ex: Ms Word, Excel, Power Point, Photoshop,
disk, RAM, ROM etc. Department of ECE, VNRVJIET, Hyderabad
MySQL etc. January 23, 2022 13
Agenda
▪ Introduction to software
▪ Operating System
▪ Computer memory
▪ Memory Management
▪ Random Access Memory
▪ Read Only Memory
▪ Secondary Memory
Byte 8 Bits 1
Zettabyte 1, 024 Exabytes 1, 180, 591, 620, 717, 411, 303, 424
CPU can read ROM without the need for drivers , load parts of the operating
system into primary memory so that it can start up and become ready to use
Types of ROM
▪ The data needs to be brought into the primary memory before the CPU
can use it
Examples:
Hard Disk, Floppy Disk, Memory Card,pen drive, CD etc
➢ Hard disks are the most famously used secondary storage devices
executable image
Run C Progrm
loaded into RAM
1. Text/Code segment
2. Data segment
3. Heap segment
4. Stack segment
1. Initialized data
▪ It contains both static and global data that initialized with non-zero
values
2. Uninitialized data
Heap segment
▪ Contains dynamically allocated memory using malloc(), calloc(), realloc()
etc
▪ We can free dynamically allocated memory space (by
using free() or delete()
▪ malloc/free eventually, cause heap fragmentation
Stack segment
▪ In this segment local variables stored
▪ When we call any function, the stack frame created and when a function
returns, the stack frame destroyed/rewind including all local variables of
that particular function
Problem
1. Flow Chart:
A flowchart can be defined as a pictorial representation of an algorithm
▪ All pseudo codes starts with keyword ‘START’ and complete with ‘STOP’ or
‘END’.
Problem-1 Problem-2
1.START 1.START
2.Read number1, number2 2.Read number1, number2
3.Sumnumber1+number2 3.If number1 > number2 then
4.Print sum 4. Print number1
5.STOP 5. Else
6. Print number2
7. STOP
1. START
2. Read n
3. Sum 0
4. For i 1 to n do
5. read numberi
6. sum sum + numberi
7. End for
8. average sum/n
9. Print average
10. STOP
•WEB APPLICATION :
A web application is a computer program that utilizes web browsers
and web technology to perform tasks over the Internet.
STANDALONE APPLICATION
▪ Must be downloaded
▪ Single user access at a time
▪ Compatible for Single OS
▪ VLC,MS-Office, Adobe Photoshop
WEB APPLICATION
▪ No need of Installation
▪ Independent to OS
▪ Face book , Gmail, IRCTC
Steps to learn C
C Tokens
In C programs, each word and punctuation is referred to as a token. C Tokens are the smallest
building block or smallest unit of a C program.
The compiler breaks a program into the smallest possible units and proceeds to the various
stages of the compilation, which is called token.
1. Primitive Data Types: Integer, character, float, void. All these are
called primitive data types.
2. Derived Data Types: Array, String, Pointer, etc. come under derived
data types.
3. User-Defined Data Types: Structure, union, typedef, enum, etc. are
comes under user-defined data types.
Primitive Data Types are classified into four types are as follows.
1. Integer
2. Character
3. Float
4. Void
▪ The Float Data Type in C language is divided into three types one is
float type, the second one is double and the last one is long double.
Float is of size 4 bytes; double is of size 8 bytes and long double is of
size 10 byte
char 1 %c
float 4 %f
double 8 %lf
short int 2 usually %hd
signed char 1 %c
unsigned char 1 %c
#include <stdio.h>
int main()
{
printf("%d",sizeof(long int));
return 0;
}
▪ void sum (int a, int b); – This function won’t return any value to the
calling function.
int sum (int a, int b); – This function will return value to the calling
function.
1. Array
2. Functions
3. Pointers
4. Structures
5. Classes
Syntax
datatype variable_name;
Example
int a,b; int a=10,b=20;
float c; float f=6.9;
char d; char c='A'
Types of Variables in C
1. local variable
2. global variable
3. static variable
4. automatic variable
5. external variable
▪ function1();
▪ function2();
▪ return 0;
▪ }
▪ Valid example:
▪ extern int a; extern int a; extern int a;
▪ Invalid example:
2. #define preprocessor
Syntax: #define token value
Ex:- #define PI 3.14
String Constants:
▪ A string constant is a sequence of characters enclosed within a pair of double
quotation marks.
Example: “abcd”, “2006”, “A+B”, “5+8” etc.
▪ Notice that the symbolic names are written in uppercase, to distinguish them
from ordinary C identifiers.
void main()
{
int a, b, c;
a + b = c; //semantic error
}
➢ Operators in C
➢ Arithmetic expressions
➢ Associativity
➢ Precedence
Operator:
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
A = 0011 1100
B = 0000 1101
-----------------
~A = 1100 0011
#include <stdio.h>
int main()
{
int m = 5, n = 4;
return 0;
}
Example:
A+B-C*D/E
Then
10*20 = 200 + 5 = 205 is evaluated based on the precedence
10 / 5 * 2
Left to Right
Associativity