PG Computer Notes 1
PG Computer Notes 1
PG Computer Notes 1
Definition of Computer:
"A computer is an electronic machine that operates under the control of instructions, that
accepts the input data, processes or manipulates the given data according to predefined
instructions and stores the result for future use"
It performs the following three operations in sequence.
1. It receives data & instructions from the input device.
2. Processes the data as per instructions.
3. Provides the result (output) in a desired form.
1. High speed: Computers have the ability to perform routine tasks at a greater speed than
human beings. They can perform millions of calculations in seconds.
2. Accuracy: Computers are used to perform tasks in a way that ensures accuracy.
3. Storage: Computers can store large amount of information. Any item of data or any
instruction stored in the memory can be retrieved by the computer at lightning speeds.
4. Automation: Computers can be instructed to perform complex tasks automatically (which
increases the productivity).
5. Diligence: Computers can perform the same task repeatedly & with the same accuracy
without getting tired.
6. Versatility: Computers are flexible to perform both simple and complex tasks.
7. Cost effectiveness: Computers reduce the amount of paper work and human effort, thereby
reducing costs.
Limitations of computers:
1. Computers need clear & complete instructions to perform a task accurately. If the
instructions are not clear & complete, the computer will not produce the required result.
2. Computers cannot think.
3. Computers cannot learn by experience.
CLASSIFICATION OF COMPUTERS
Computers are broadly classified into two categories depending upon the logic used in their
design as:
1. Analog computers:
In analog computers, data is recognized as a continuous measurement of a physical property
like voltage, speed, pressure etc. Readings on a dial or graphs are obtained as the output, ex.
Voltage, temperature; pressure can be measured in this way.
2. Digital Computers:
These are high speed electronic devices. These devices are programmable. They process data
by way of mathematical calculations, comparison, sorting etc. They accept input and produce
output as discrete signals representing high (on) or low (off) voltage state of electricity.
Numbers, alphabets, symbols are all represented as a series of 1s and 0 s.
Digital Computers are further classified as General Purpose Digital Computers and Special
Purpose Digital Computers. General Purpose computers can be used for any applications like
accounts, payroll, data processing etc. Special purpose computers are used for a specific job
like those used in automobiles, microwaves etc.
3. Hybrid Computers:
Hybrid Computers are a combination of Analog and Digital computers. They combine the
speed of analog computers and accuracy of digital computers. They are mostly used in
specialized applications where the input data is in an analog form i.e. measurement. This is
converted into digital form for further processing. The computers accept data from sensors and
produce output using conventional input/output devices. Another classification of digital
computers is done on the basis of their capacity to access memory and size like:
Computers are classified into four categories depending upon the size, memory capacity and
speed as:
1. Microcomputers:
Microcomputers are generally referred to as Personal Computers (PCs). They have smallest
memory and less power. They are widely used in day to day applications like office automation,
and professional applications, ex. PCAT, Pentium , Note Book and Laptop Computers etc.
2. Mini Computers: Mini computers are more powerful than the microcomputers. They
have higher memory capacity and more storage capacity with higher speeds. These
computers are mainly used in process control systems. They are mainly used in
applications like payrolls, financial accounting, Computer aided design etc. ex. VAX,
PDP-11
3. Mainframe Computers: Main frame computers are very large computers which
process data at very high speeds of the order of several million instructions per second.
They can be linked into a network with smaller computers, microcomputers and with
each other. They are typically used in large organizations, government departments etc.
ex. IBM4381, CDC.
4. Super Computers: A super computer is the fastest, most powerful and most expensive
computer which is used for complex tasks that require a lot of computational power.
Super computers have multiple processors which process multiple instructions at the
same time. This is known as parallel processing. These computers are widely used in
very advanced applications like weather forecasting, processing geological data etc. ex.
CRAY-2, NEC - 500, PARAM.
Generation of Computer:
1. First Generation Computers
The first-generation computers that were in use from 1946 to 1959 used vacuum tubes
and magnetic drums as the basic components of the CPU and memory.
They were very massive in size and had a large amount of energy loss in the form of
heat.
The frequent fusing of the installations made them very expensive.
ENIAC (Electronic Numerical Integrator and Calculator), EDVAC, UNIVAC, IBM-
701, IBM-650, etc., were some first-generation computers.
2. Second Generation Computers
In the second generation of computers, cheaper, low-power-consuming, compact-sized,
reliable, and faster transistors were used as the building blocks of the CPU.
These computers that were in use from 1959 to 1965 used magnetic cores, tapes, and
discs as storage devices.
The use of batch processing, multiprogramming operating systems, and high-level
programming languages like FORTRAN and COBOL were some of the features of
second-generation computers like IBM 1620, IBM 7094, CDC 1604, CDC 3600,
UNIVAC 1108, etc.
3. Third-Generation Computers
The third generation computers that were in use from 1965 to 1971 used Integrated
Chips (IC's) invented by Jack Kilby as the basic component of the CPU.
The use of IC's helped to invent more reliable, efficient, and smaller-sized computers
like the IBM-360 series, Honeywell-6000 series, PDP (Personal Data Processor), IBM-
370/168, etc.
Use of remote sensing, time-sharing, and high-level programming languages like
FORTRAN - II to IV, COBOL, PASCAL PL/1, BASIC, ALGOL-68, etc. were the
salient features of third-generation computers.
4. Fourth Generation Computers
The fourth generation computers that were in use from 1971 to 1980 used Very Large
Scale Integrated (VLSI) circuits in the CPU.
The powerful, compact, reliable, and affordable fourth-generation computers like
Micral, IBM 5100, Altair 8800, etc., led to the beginning of the Personal Computer era.
The use of real-time networks, distributed operating systems, and high-level
programming languages like C, C++, DBASE, etc. were some of the features of fourth-
generation computers.
5. Fifth Generation Computers
The fifth generation computers that have been in use from 1980 to date use
microprocessors that work on Ultra Large Scale Integration (ULSI) technology.
Artificial Intelligence software and parallel processing hardware are the peculiarities of
fifth-generation computers like PDP-8, PDP-11, ICL 2900, IBM 360, IBM 370, etc.
All high-level languages, such as C, C++, Java,.Net, and others, are used in today's
computers.
Computer Hardware:
Computer hardware is a physical device of computers that we can see and touch. For e.g.
Monitor, Central Processing Unit, Mouse, Joystick, etc. Using these devices, we can control
computer operations like input and output.
Computer Hardware Parts-
These hardware components are further divided into the following categories, which are:
Input Devices
Output Devices
Storage Devices
Processor unit
1. Input Devices: Devices used to provide data and instructions to the computer are called
Input devices. Some important input devices are:-
Key board, Mouse, Scanner, MICR, Web camera, Microphone etc.
1. Keyboard: The Key board is used for typing text into the computer. It is also
known as standard Input device. A computer keyboard is similar to that of a type
writer with additional keys. The most commonly available computer keyboard
has 104 keys.
There are different types of keys on the keyboard. The keys are categorized as :
Punctuation keys, such as colon (:), semicolon (;) Question mark (?),
Single & doublequotes (‗,‖)
Special keys such as arrow keys, control keys, function keys (F1 to F12), HOME,
END etc.
2. Mouse: It is a device that controls the movement of the cursor on a monitor. A mouse
will have 2 buttons on its top. The left button is the most frequently used button. There
will be a wheel between the left and right buttons. This wheel enables us to smoothly
scroll through screens of information. As we move the mouse, the pointer on the monitor
moves in the same direction. Optical mouse is another advanced pointing device that
uses a light emitting component instead of the mouse ball. Mouse cannot be used for
entering the data. It is only useful to select the options on the screen.
3. Scanner: : It is an input device that can read text or illustrations printed on paper
and translate intodigital form. The main advantage of these scanners is that the data
need not be entered separately resulting in saving lot of time.
2. Output Devices
These are the devices that are used to display the output of any task given to the computer in
human-readable form. For example Monitor, printer, plotter, speaker etc.
3. Storage Devices
Memory or storage unit is one of the important components of a computer. It is also known as
the primary storage or main memory. It stores data, program instructions, internal results and
final output temporarily before it is sent to an appropriate output device. It consists of
thousands of cells called ―storage locations‖. These cells activate with ―off-on‖ or binary
digits (0,1) mechanism. Thus a character either a letter or numerical digit is stored as a string
of (0,1) Binary digits ( BITS). These bits are used to store instructions and data by their
combinations.
Any storage unit of a computer system is classified on the basis of the following criteria:
Access time: This is the time required to locate and retrieve stored data from the storage unit
in response to program instructions.
Storage capacity: It is the amount of data that can be stored in the storage unit.
Cost per bit of storage.
Units of memory: The computer stores a character in the storage cells with binary (0,1)
mechanism. Thus the basic unit of memory is a bit (binary digit – 0,1). To store a character, a
computer requires 8 bits or 1 byte. This is called the ― word length‖ of the storage unit. Hence
the storage capacity of the computer is measured in the number of words it can store and is
expressed in terms of bytes. The different units of measurement are
Conversion :
8 bits = 1 Byte
210 (or) 1024 Bytes = 1 Kilo Byte (KB)
210 (or) 1024 KB = 1 Mega Byte (MB)
210 (or) 1024 MB = 1 Gega Byte (GB)
210 (or) 1024 GB = 1 Tera Byte (TB)
210 (or) 1024 TB = 1 Peta Byte (PB)
Hard Disk: The hard disk can hold more information than the floppy disk and the retrieval
of information from hard disk is faster when compared to floppies or tapes. A hard disk is fixed
inside the CPU and its capacity ranges from 20 MB onwards. The hard disk is made up of a
collection of discs (one below the other) known as platters on which the data is recorded. These
platters are coated with magnetic material. It is less sensitive to external environmental
disorders and hence the storage in hard disk is safe. A small hard disk might be as much as 25
times larger than a floppy disk. Storage Capacity of hard disks varies from 20 MB to several
Gega bytes like 80GB, 160GB.
CD-ROM: CD-ROM stands for Compact Disk–Read Only Memory. It is used to store a wide
variety of information. Its main advantage is that it is portable and can hold a large amount of
data.. The storage capacity of most CD-ROMs is approximately 650 MB or 700 MB.
DVD: DVD stands for Digital Versatile Disc. It is similar to a CD-ROM, except that it can
store larger amounts of data. The storage capacity of a DVD is at least 4.7MB. DVDs that can
store up to 17GBs are also available. Because of their capacity, DVDs are generally used to
store a very large multimedia presentations and movies that combine high quality sound and
graphics.
Flash Drive: It is a small, portable device that can be used to store, access and transfer data.
Due to its small size, it is commonly called Pen drive. It is also called USB drive. We can read,
write, copy, delete, and move data from computer to pen drive or pen drive to computer. It
comes in various storage capacities of 2GB, 4GB, 8GB etc. It is popular because it is easy to
use and small enough to be carried in a pocket. This device is plugged into the USB port of the
computer and the computer automatically detects this device.
Central Processing Unit: It is the part of the computer that carries out the instructions of a
computer program. It is the unit that reads and executes program instructions. Hence it is known
as the brain‖ of the computer. The CPU consists internal Registers, Arithmetic Logic Unit
(ALU) and control unit.
Von-Neumann computer architecture design was proposed in 1945.It was later known as Von-
Neumann architecture. Historically there have been 2 types of Computers:
Fixed Program Computers – Their function is very specific and they couldn’t be
reprogrammed, e.g. Calculators.
Stored Program Computers – These can be programmed to carry out many different tasks,
applications are stored on them, hence the name.
Von Neumann architecture is based on the stored-program computer concept, where instruction
data and program data are stored in the same memory. This design is still used in most
computers produced today.
A Von Neumann-based computer:
Uses a single processor
Uses one memory for both instructions and data.
Executes programs following the fetch-decode-execute cycle
It is also known as ISA (Instruction set architecture) computer and is having four basic units:
1. The Central Processing Unit (CPU)
2. The Memory Unit
3. The Input and Output Device
4. Buses
1. Central Processing Unit-
The central processing unit is defined as the it is an electric circuit used for the executing the
instruction of computer program.
It has following major components:
i. Control Unit(CU)
ii. Arithmetic and Logic Unit(ALU
iii. variety of Registers
i. Control Unit –
A control unit (CU) handles all processor control signals. It directs all input and output flow,
fetches code for instructions, and controls how data moves around the system.
ii. Arithmetic and Logic Unit (ALU) –
The arithmetic logic unit is that part of the CPU that handles all the calculations the CPU may
need, e.g. Addition, Subtraction, Comparisons. It performs Logical Operations, Bit Shifting
Operations, and Arithmetic operations.
iii. Registers – Registers refer to high-speed storage areas in the CPU. The data processed
by the CPU are fetched from the registers. There are different types of registers used
in architecture :-
Accumulator: Stores the results of calculations made by ALU. It holds the intermediate of
arithmetic and logical operatoins.it act as a temporary storage location or device.
Program Counter (PC): Keeps track of the memory location of the next instructions to be
dealt with. The PC then passes this next address to the Memory Address Register (MAR).
Memory Address Register (MAR): It stores the memory locations of instructions that need
to be fetched from memory or stored in memory.
Memory Data Register (MDR): It stores instructions fetched from memory or any data that
is to be transferred to, and stored in, memory.
Current Instruction Register (CIR): It stores the most recently fetched instructions while it
is waiting to be coded and executed.
Instruction Buffer Register (IBR): The instruction that is not to be executed immediately is
placed in the instruction buffer register IBR.
2. Memory Unit: A memory unit is a collection of storage cells together with associated
circuits needed to transfer information in and out of the storage. The memory stores binary
information in groups of bits called words. The internal structure of a memory unit is specified
by the number of words it contains and the number of bits in each word.
The memory component in Von Neumann Architecture consists of primary and secondary
memory
3. Input and Output Devices – Program or data is read into main memory from the input
device or secondary storage under the control of CPU input instruction. Output devices are
used to output information from a computer. If some results are evaluated by the computer and
it is stored in the computer, then with the help of output devices, we can present them to the
user.
4. Buses – Data is transmitted from one part of a computer to another, connecting all major
internal components to the CPU and memory, by the means of Buses. Types:
Data Bus: It carries data among the memory unit, the I/O devices, and the processor.
Address Bus: It carries the address of data (not the actual data) between memory and processor.
Control Bus: It carries control commands from the CPU (and status signals from other devices)
in order to control and coordinate all the activities within the computer.
Access Time: It is the time interval between the read/write request and the availability of
the data. As we move from top to bottom in the Hierarchy, the access time increases.
Performance: Earlier when the computer system was designed without a Memory
Hierarchy design, the speed gap increased between the CPU registers and Main Memory
due to a large difference in access time. This results in lower performance of the system
and thus, enhancement was required. This enhancement was made in the form of Memory
Hierarchy Design because of which the performance of the system increases. One of the
most significant ways to increase system performance is minimizing how far down the
memory hierarchy one has to go to manipulate data.
Cost per Bit: As we move from bottom to top in the Hierarchy, the cost per bit increases
i.e. Internal Memory is costlier than External Memory.
Computer Software
Software: Software is a program or set of instructions that causes the Hardware to function
in a desired way. The basic difference between the Hardware and Software is just the same
as that exists between TV and TV studio. Without TV studio (software) from where the
programs are telecast, the TV (Hardware) is a dead machine.
There are five categories of software. They are:
1. Operating System 2. Translators 3. Utility programs 4. Application programs
5. General purpose programs
Generally the OS acts as an interface between the user and the Hardware of the
computer. i.e It is a bridge between the user and the Hardware.
The User interface provided by the OS can be character based or graphical.
CUI -- Character user Interface
GUI -- Graphical user Interface
CUI : It is operated with keyboard only. Ex: MS-DOS, UNIX
GUI : The system can be operated with mouse and keyboard. Ex: Windows 95,
Windows XP etc
Functions of Operating System:
1. Memory Management: It is the management of the main or primary memory. It
Allocates and deallocates the memory.
Keeps a record of which part of primary memory is used by whom and how much.
Distributes the memory while multiprocessing.
In multiprogramming, the operating system selects which processes acquire memory
when and how much memory they get.
2. Processor Management/Scheduling
When more than one process runs on the system the OS decides how and when a process will
use the CPU. Hence, the name is also CPU Scheduling. The OS:
Allocates and deallocates processor to the processes.
Keeps record of CPU status.
3. Device Management
An operating system regulates device connection using drivers. The processes may require
devices for their use. This management is done by the OS. The OS:
Allocates and deallocates devices to different processes.
Keeps records of the devices.
Decides which process can use which device for how much time.
4. File Management
The files on a system are stored in different directories. The OS:
Keeps records of the status and locations of files.
Allocates and deallocates resources.
Decides who gets the resources.
5. Storage Management
Storage management is a procedure that allows users to maximize the utilization of storage
devices while also protecting data integrity on whatever media on which it lives. The OS uses
storage management for:
Improving the performance of the data storage resources.
It optimizes the use of various storage devices.
Assists businesses in storing more data on existing hardware, speeding up the data
retrieval process, preventing data loss, meeting data retention regulations, and lowering
IT costs.
Types of Operating Systems
There are several types of Operating Systems which are mentioned below.
Batch Operating System
Multi-Programming System
Multi-Processing System
Multi-Tasking Operating System
Time-Sharing Operating System
Distributed Operating System
Network Operating System
Real-Time Operating System
1. Batch Operating System
This type of operating system does not interact with the computer directly. There is an operator
which takes similar jobs having the same requirement and groups them into batches. It is the
responsibility of the operator to sort jobs with similar needs.
Basics of DOS Programming: Separate PDF file created for DOS commands.
Programming Language Translator:
Compilers, interpreters, translate programs written in high-level languages into machine code
that a computer understands and assemblers translate programs written in low-level or
assembly language into machine code.
The language processors can be any of the following three types:
1. Compiler
The language processor that reads the complete source program written in high-level language
as a whole in one go and translates it into an equivalent program in machine language is called
a Compiler. Example: C, C++, C#.
2. Assembler
The Assembler is used to translate the program written in Assembly language into machine
code. The source program is an input of an assembler that contains assembly language
instructions. The output generated by the assembler is the object code or machine code
understandable by the computer. Assembler is basically the 1st interface that is able to
communicate humans with the machine. We need an assembler to fill the gap between human
and machine so that they can communicate with each other. code written in assembly language
is some sort of mnemonics(instructions) like ADD, MUL, MUX, SUB, DIV, MOV and so on.
and the assembler is basically able to convert these mnemonics in binary code. Here, these
mnemonics also depend upon the architecture of the machine.
3. Interpreter
The translation of a single statement of the source program into machine code is done by a
language processor and executes immediately before moving on to the next line is called an
interpreter. If there is an error in the statement, the interpreter terminates its translating process
at that statement and displays an error message. The interpreter moves on to the next line for
execution only after the removal of the error. An Interpreter directly executes instructions
written in a programming or scripting language without previously converting them to an object
code or machine code. An interpreter translates one line at a time and then executes it.
Computer Networks:
What is a Computer Network:-
In a network, two or more computers are connected in a way so that they can share their
resources like printers, CDs, hard disks etc. Such networks can be connected via cable,
telephone line, radio waves, satellite, infrared etc.
Types of Computer Network
Based on coverage or geographical spread, a network can be divided into the following
types: LAN, MAN, WAN and PAN.
1. Local Area Network (LAN) -When the network of computer is confined to a small or
localised area such as school, office or building, it is known as Local Area Network (LAN).
Computers or users in a local area network can share data, information, software and common
hardware devices such as printer, modem, hard disk, etc.
2. Metropolitan Area Network (MAN)- A metropolitan area network is the network which is
spread over a city. The functions of a MAN is similar to LAN. Like a LAN, computers in a
MAN are also capable of sharing data, information, software and hardware. The difference is
only on the basis of geographical area coverage.
3. Wide Area Network (WAN)- The network of computers which is spread across the countries
probably over the entire world is known as a Wide Area Network (WAN).
A WAN can be a group of several LANs interconnected together.
The largest WAN is the Internet.
The functions of WAN are also similar to a LAN or MAN.
4. Personal Area Network (PAN) -The PAN refers to a computer network, which is used for
communication among computer devices spread over a few meters. PAN may be wired (i.e.
with the use of computer buses such as USB) or wireless using wireless network technologies
such as Bluetooth, wireless USB, Z-wave and ZigBee. Bluetooth personal area network (PAN)
is also called a piconet. It can be composed of up to eight devices in a master-slave relationship.
The first Bluetooth device is master and other devices are acting as slaves. Normally, its range
is up to 10 m.
Definition of Internet-
The Internet has gained popularity and emerged as an important and efficient means of
communication. The Internet is a worldwide network of networks.
Through the Internet, computers become able to exchange information with each other and find
diverse perspectives on issues from a global audience.
Applications of Internet
The Internet is used for different purposes by different people. Some uses of the Internet are
listed below:
E-Commerce (auction, buying, selling products etc.)
Research (online journals, magazines, information etc.)
Education (e-learning courses, virtual classroom, distance learning)
E-Governance (online filing of application (Income Tax), online application forms
etc.)
Online ticket booking (airplane tickets, rail tickets, cinema hall tickets etc.)
On-line payments (credit card payments etc.)
Video conferencing
Exchange of views, music, files, emails, folders, data, information etc.
Outsourcing jobs (workflow software)
Social networking (sites like Facebook, LinkedIn, X)
E-telephony (sites like skype)
Components of a C Program:
1. Header Files Inclusion – Line 1 [#include <stdio.h>]
What is header files in C ?
The first and foremost component is the inclusion of the Header files in a C program. A header
file is a file with extension .h which contains C function declarations and macro definitions
to be shared between several source files. All lines that start with # are processed by a
preprocessor which is a program invoked by the compiler. In the above example, the
preprocessor copies the preprocessed code of stdio.h to our file. The .h files are called header
files in C.
Some of the C Header files:
Windows: There are many free IDEs available for developing programs in C like Code Blocks
and Dev-CPP. IDEs provide us with an environment to develop code, compile it and finally
execute it. We strongly recommend Code Blocks.
Linux: GCC compiler comes bundled with Linux which compiles C programs and generates
executables for us to run. Code Blocks can also be used with Linux.
macOS: macOS already has a built-in text editor where you can just simply write the code and
save it with a “.c” extension.
Application of C :
Operating systems: C is widely used for developing operating systems such as Unix, Linux,
and Windows.
Embedded systems: C is a popular language for developing embedded systems such as
microcontrollers, microprocessors, and other electronic devices.
System software: C is used for developing system software such as device drivers, compilers,
and assemblers.
Networking: C is widely used for developing networking applications such as web servers,
network protocols, and network drivers.
Database systems: C is used for developing database systems such as Oracle, MySQL, and
PostgreSQL.
Gaming: C is often used for developing computer games due to its ability to handle low-level
hardware interactions.
Artificial Intelligence: C is used for developing artificial intelligence and machine learning
applications such as neural networks and deep learning algorithms.
Scientific applications: C is used for developing scientific applications such as simulation
software and numerical analysis tools.
Financial applications: C is used for developing financial applications such as stock market
analysis and trading systems.
What is a variable in C?
A variable in C is a memory location with some name that helps store some form of data and
retrieves it when required. We can store different types of data in the variable and reuse the
same variable for storing some other data any number of times.
C Variable Syntax
The syntax to declare a variable in C specifies the name and the type of the variable.
Variable Declaration
Variable Definition
Variable Initialization
1. C Variable Declaration
Variable declaration in C tells the compiler about the existence of the variable with the given
name and data type.When the variable is declared compiler automatically allocates the memory
for it.
2. C Variable Definition
In the definition of a C variable, the compiler allocates some memory and some value to it. A
defined variable will contain some random garbage value till it is not initialized.
Ex: int var;
char var2;
3. C Variable Initialization
Initialization of a variable is the process where the user assigns some meaningful value to the
variable.
int var; // variable definition
var = 10; // initialization
or
int var = 10;
Rules for Naming Variables in C
You can assign any name to the variable as long as it follows the following rules:
A variable name must only contain alphabets, digits, and underscore.
A variable name must start with an alphabet or an underscore only. It cannot start with a digit.
No whitespace is allowed within the variable name.
A variable name must not be any reserved word or keyword.
Data Types in C :
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
Run Code
Output
Hello, World!
Flowchart:
C code:
#include <stdio.h>
int main()
{
int x, y, sum; // Declare variables for two integers and their
sum
Sample Output:
Input the first integer: 25
Algorithm :
Step 1: Start
Step 2: Get the inputs from the user for five subjects mark
Step 3: Find the Total of the marks
Step 4: Find the percentage using formula (percentage = total of the marks
divided by no. of the subjects)
Step 5: Print sum of the marks and percentage.
Step 6: stop
#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3,s4,s5,total=500,sum=0;
float percentage;
printf("Enter Marks of 5 Subjects: ");
scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
sum=s1+s2+s3+s4+s5;
printf("Sum of 5 Subjects is: %d\n",sum);
percentage=(sum*100)/total;
printf("Percentage is: %f",per);
}
Copy
OUTPUT:
Flowchart:
Start
sum=s1+s2+s3+s4+s5
Percentage= (sum*100)/total
Stop