C Programing Manual 2015 (Updated)
C Programing Manual 2015 (Updated)
C Programing Manual 2015 (Updated)
Subject Code:14CPL16/14CPL26
Hours/Week:03
Total Hours:42
IA Marks:25
Exam. Hours:03
Exam. Marks:50
Sl
No.
Program Name
Page
No.
1
2
3
4
5
6
7
Write-up onRAM, SDRAM, FLASH memory, Hard disks, Optical media, CDROM/R/RW, DVDs, Flash drives, Keyboard, Mouse, Printers and
Plotters.Introduction to flowchart, algorithm and pseudo code.
PART B: Problem Solving in C
Design and develop a flowchart or an algorithm that takes three coefficients
(a, b, and c) of a Quadratic equation (ax2+bx+c=0) as input and compute all
possible roots. Implement a C program for the developed
flowchart/algorithm and execute the same to output the possible roots for a
given set of coefficients with appropriate messages.
Design and develop an algorithm to find the reverse of an integer number
NUM and check whether it is PALINDROME or NOT. Implement a C program
for the developed algorithm that takes an integer number as input and
output the reverse of the same with suitable messages. Ex: Num: 2014,
Reverse: 4102, Not a Palindrome.
a. Design and develop a flowchart to find the square root of a given number
N. Implement a C program for the same and execute for all possible inputs
with appropriate messages. Note: Dont use library function sqrt (n).
b. Design and develop a C program to read a year as an input and find
whether it is leap year or not. Also consider end of the centuries.
Design and develop an algorithm for evaluating the polynomial f(x) = a4x4+
a3x3 +a2x2+a1x+a0 for a given value of x and its coefficients using Horners
method. Implement a C program for the developed algorithm and execute for
different sets of values of coefficients and x.
Draw the flowchart and write C Program to compute Sin(x) using Taylor
series approximation given by Sin(x) = x - (x3/3!) + (x5/5!) - (x7/7!) + .
Compare the result with the built- in Library function and print both the
results with appropriate messages.
Develop an algorithm, implement and execute a C program that reads N
integer numbers and arrange them in ascending order using Bubble Sort.
Develop, implement and execute a C program that reads two matrices A (m x
n) and B (p x q) and Compute the product A and B. Read matrix A in row
major order and matrix B in column major order. Print both the input
8
9
10
11
12
13
14
matrices and resultant matrix with suitable headings and in matrix format.
Program must check the compatibility of orders of the matrices for
multiplication. Report appropriate message in case of incompatibility.
Develop, implement and execute a C program to search a Name in a list of
names using Binary searching technique.
Write and execute a C program that
i. Implements string copy operation STRCOPY (str1, str2) that copies a
string str1 to another string str2 without using library function.
ii. Reads a sentence and prints frequency of each of the vowels and total
count of consonants.
a. Design and develop a C function RightShift (x, n) that takes two integers x
and n as input and returns value of the integer x rotated to the right by n
positions. Assume the integers are unsigned. Write a C program that invokes
this function with different values for x and n and tabulate the results with
suitable headings.
b. Design and develop a C function isprime (num) that accepts an integer
argument and returns 1 if the argument is prime, a 0 otherwise. Write a C
program that invokes this function to generate prime numbers between the
given ranges.
Draw the flowchart and write a recursive C function to find the factorial of a
number, n!. Defined by fact (n) =1, if n=0. Otherwise fact (n) =n*fact (n-1).
Using this function, write a C program to compute the binomial coefficient C.
Tabulate the results for different values of n and r with suitable messages.
Given two university information files studentname.txt and usn.txt that
contains students Name and USN respectively. Write a C program to create a
new file called output.txt and copy the content of files studentname.txt
and usn.txt into output file in the sequence shown below. Display the
contents of output file output.txt on to the screen.
Student Name
USN
Name 1
USN1
Name 2
USN2
.
.
.
.
.
.
Write a C program to maintain a record of n student details using an array
of structures with four fields (Roll number, Name, Marks, and Grade). Each
field is of an appropriate data type. Print the marks of the student given
student name as input.
Write a C program using pointers to compute the sum, mean and standard
deviation of all elements stored in an array of n real numbers.
Viva-Voce Questions
Reference Book :
ReemaThareja, Computer Fundamentals and Programming in C ,Oxford Press, 2012.
Activity
Writing the assigned program along with Algorithm and Flowchart
Execution of the program and displaying the output ina proper format
Viva-Voce
Total Maximum Marks
Minimum passing Marks (40% of Total Maximum Marks)
Max Marks
10
30
10
50
20
Hardware represents the physical and tangible components of the computer, i.e., the
components that can be seen and touched.
Sl. No.
Operation
Description
Receive Input
Output
Information
4
5
Processing
Data
Store Data
Control
the Direct the manner and sequence in which all of the above
workflow
operations are performed.
CPU
Consists of the following features:
CPU is considered as the brain of the computer.
CPU performs all types of data processing operations.
It stores data, intermediate results and instructions (program).
Arithmetic section
Function of Arithmetic section is to perform arithmetic operations like addition,
subtraction, multiplication and division. All complex operations are done by making
repetitive use of above operations.
Logic section
Function of logic section is to perform logic operations such as comparing, selecting,
matching and merging of data.
Cache Memory
Cache memory is a very high speed semiconductor memory which can speed up CPU. It acts
as a buffer between the CPU and main memory. It is used to hold those parts of data and
program which are most frequently used by CPU. The parts of data and programs are
transferred from disk to cache memory by operating system, from where CPU can access
them.
Advantage
Cache memory is faster than main memory.
It consumes less access time as compared to main memory.
It stores the program that can be executed within a short period of time.
It stores data for temporary use.
Disadvantage
Cache memory has limited capacity.
It is very expensive.
A RAM constitutes the internal memory of the CPU for storing data, program and program
result. It is read/write memory. It is called random access memory (RAM). Since access
time in RAM is independent of the address to the word that is, each storage location inside
the memory is as easy to reach as other location & takes the same amount of time. We can
SRAM Chip
The word static indicates that the memory retains its contents as long as power remains
applied. However, data is lost when the power gets down due to volatile nature. SRAM
chips use a matrix of 6-transistors and no capacitors. Transistors do not require power to
prevent leakage, so SRAM need not have to be refreshed on a regular basis. Because of the
extra space in the matrix, SRAM uses more chips than DRAM for the same amount of
storage space, thus making the manufacturing costs higher. Static RAM is used as cache
memory needs to be very fast and small. Characteristic of the Static RAM
It has long data lifetime
There is no need to refresh
Faster
Used as cache memory
Large size
Expensive
High power consumption
Secondary Memory
This type of memory is also known as external memory or non-volatile. It is slower than
main memory. These are used for storing Data/Information permanently. CPU directly
does not access these memories instead they are accessed via input-output routines.
Contents of secondary memories are first transferred to main memory, and then CPU can
access it. For example: disk, CD-ROM, DVD etc. Characteristic of Secondary Memory
These are magnetic and optical memories.
It is known as backup memory.
It is non-volatile memory.
Data is permanently stored even if power is switched off.
It is used for storage of the data in the computer.
Computer may run without secondary memory.
Slower than primary memories.
Control Unit
This unit controls the operations of all parts of computer. It does not carry out any actual
data processing operations. Functions of this unit are
It is responsible for controlling the transfer of data and instructions among other
units of a computer.
It manages and coordinates all the units of the computer.
It obtains the instructions from the memory, interprets them and directs the
operation of the computer.
It communicates with input/output devices for transfer of data or results from
storage.
It does not process or store data.
Input unit
The input device is used to enter data and information into a computer.
The devices like keyboard, mouse and scanner are commonly used as input devices.
A keyboard is used to enter alphanumeric characters and symbols.
The mouse is used to pick or select a command from the monitor screen.
A scanner is used to scan an image or read a barcode and so on.
Output Unit
The output device is used to display or print result from a computer. Monitor, printer and
plotter are commonly used output devices. A monitor is used to display the result in the
form of text and graphics. The printer is used to print the result. A plotter is used to plot or
print graphical result from a computer. Note that a result displayed in a monitor is
temporary and it disappears when the next result is displayed, whereas the output printed
using a printer or a plotter is permanent and these printouts can be used for any business
correspondence or documentation. Normally soft copy is referred to information that is
stored on the storage device. A hard copy refers to a printout showing the information.
Microprocessor
A microprocessor is the heart of the computer. It is a semiconductor chip, which is
manufactured using the Large Scale integration (LSI) or Very Large Scale Integration
(VLSI), which comprises Arithmetic Logic Unit, Control unit and Central Processing Unit
(CPU) fabricated on a single chip. Intel 8088, Motorola 68000 are few microprocessors.
System Bus
The system bus is a cable which carries data communication between the major
components of the computer, including the microprocessor. Not all of the communication
that uses the bus involves the CPU, although naturally the examples used in this tutorial
will centre on such instances.
The system bus consists of three different groups of wiring, called the data bus, control bus
and address bus. These all have separate responsibilities and characteristics, which can be
outlined as follows:
Control Bus
The control bus carries the signals relating to the control and co-ordination of the various
activities across the computer, which can be sent from the control unit within the CPU.
Different architectures result in differing number of lines of wire within the control bus, as
each line is used to perform a specific task. For instance, different, specific lines are used
for each of read, write and reset requests.
I/O Bus
A personal computer may transfer data from disk to CPU, from CPU to memory, or from
memory to the display adapter. I/O buses connect all I/O devices with the CPU and RAM. In
modern Pentium driven PC, there are two or three different I/O Buses.
The ISA (Industry Standard Architecture) Bus - oldest, simplest and slowest bus.
ISA is a type of bus used in PCs for adding expansion cards. For example, an ISA slot
may be used to add a video card, a network card, or an extra serial port.
The PCI (Peripheral Component Interconnect) Bus Fastest and presently most
powerful bus. PCI is an interconnection system between a microprocessor and
attached devices in which expansion slots are spaced closely for high speed
operation. Using PCI, a computer can support both new PCI cards while continuing
to support Industry Standard Architecture (ISA) expansion cards, an older
standard.
The USB (Universal Serial Bus) newest bus. It is most used on Personal
computers. USB is also used on other devices such as the PlayStation 2, PlayStation
3 and the Xbox 360. USB connects different devices using a standard interface.
Most people use USB for computer mice, keyboards, scanners, printers, digital cameras,
and USB flash drives. The standard was made to improve plug and play devices. This means
that a device can simply be plugged into a free socket. The computer will then recognize it.
Operating systems and its functions:
An operating system is a program that acts as an interface between the software and
the computer hardware.
It is an integration set of specialized programs that are used to manage overall
resources and operations of the computer.
It is specialized software that controls and monitors the execution of all other
programs that reside in the computer, including application programs and other
system software.
We know operating system is a collection of programs and it is the interface between user
and the computer. An operating system is a program which connects the user and the
electronic hardware in a computer. It is a set of programs which supervise the activities of
a computer and activate the operations of the hardware components such as CPU, main
memory, disk drives, keyboard, monitor and printer and so on. Some of the startup
programs initially loaded to RAM are stored in ROM, mainly the BIOS programs which are
recorded by the manufacturers of the computer system. Service programs available in
operating system for operating system for operations like copying a file, deleting a file,
formatting a disk, printing a file and so on are usually stored in the disk. Error messages are
displayed on the screen if there is any malfunctioning of hardware.
There are many operating system used in computers. Commonly used operating systems
are MS-DOS (Microsoft Disk operating System), Windows 95/98/2000, Windows NT, UNIX
and so on. Nowadays Windows 2000 operating system is widely used in personal
computers, and UNIX is used in Mainframes, Servers, Graphic Workstations and also
personal computers. Linux is one of the most popular free operating system.
Operating system will display instruction on the monitor screen and the user can
interact with the computer.
It loads the application programs such as MS Word, AutoCAD and so on from disk to
the computer memory.
It manages the information stored on disk and retrieves the same whenever required.
It supervises and coordinates the activities of the hardware and peripherals such as
CPU, keyboard, mouse, monitor, printer, RAM, disk drives and so on.
It utilizes the power of the CPU for multitasking and timesharing.
In general operating systems performs many task which include
Memory management
Process management
I/O management
Device management
Multitasking
It is the ability of the computer to handle several application programs concurrently.
Printing a document, executing a program and any other operation can be done
simultaneously to reduce the idle time of the processor. The multi task capability of the
Timesharing
It is the ability of the CPU to serve many users connected to it through a network. The
operating system will assign each user a slice of processor time or time quantum in a
round-robin fashion. Since the CPU has high processing speed, it can process information of
many users.
Directory:
DOS uses a filing system to store its files. The filing system uses storage areas called
directories. A directory is nothing more than an expandable file folder that can hold other
expandable file folders. These file folders hold the data files. A directory is a table of
contents for a disk. It contains the names of files, their sizes, and the dates they were last
modified. All of the different directories are stored under one master directory. This
directory is called the root directory.
In addition to directories, it uses an area on a disk called the File Allocation Table (FAT).
The FAT is similar to our contents page in our book. It holds the information where the file
is stored in the disk.
Multilevel directories:
When there are two or more users who share a computer, when you are working on
several different projects, the number of files in the directory can become a large and
Multitasking:
It refers to performing a number of tasks simultaneously. For example when a document is
printed, you may run another program to sort large data and at the same time you may edit
a document in the foreground screen. UNIX switches between the tasks and executes them
one by one at small interval of time. This process of sharing the CPU to perform various
tasks simultaneously is called time-sharing. The more number of the tasks are submitted
then we end up with slower response from the computer.
Multi-user capability:
UNIX allows the computer to be used by several users through several terminal connected
to a powerful computer. A terminal will have a keyboard and a monitor. The computer to
which terminals are connected is called as the host computer or server. Any user on the
terminal can run various programs, read file information or print a document at the same
time. Multi user computer, are economical and efficient compared to stand-alone
computers.
Portability:
One of the outstanding features of UNIX is its ability to port itself to another installation.
For example, an application program developed in UNIX environment can be used in a
different platform.
Security
UNIX provides a good security for users. The users are required to authenticate before they
use the system. The password is encrypted.
File system
UNIX identifies three types of users, owner, group and others. For each group it provides
permission on the files like to read, write and execute operation.
We know, in information technology era, sharing of resources and easy communication are
acting as a backbone of any network. Popular example is our Internet. With the help of
internet we are able to exchange information and share resources. Hence in this chapter we
study different advantages of the network and different forms of the network and their
features.
Networking of computers and its advantages.
Computer network is defined as an interconnection of autonomous computer. Here
autonomous means, there is no master and slave relationship. All computers are equal.
Network offers the opportunity to communicate more efficiently with others through
electronic mail. Networks allow companies to share software and peripherals such as
printers, plotters, scanners and so on. With networking all the computers in an office can
be connected to a single printer and scanner. It also helps in using storage devices
efficiently. Computer network acts as a very powerful communication medium. It means
people exchange their information. When compared to mainframe computers, network of
computers saves money.
Types of networks
Depending the nature of the distances, protocols (the set of rules used for communication)
the network can be classified into LAN (Local Area Network), MAN (Metropolitan Area
Network) and WAN (Wide Area Network).
Internet
The internet is a massive wide area network, connecting thousands of computer networks
around the world. The internet is a worldwide network of networks. It is a collection of
thousands of smaller networks in different countries around the world. It links thousands
of academic government, military and public computers, enabling millions of people to
share information and other resources.
Internet pathways are used to exchange digitized computer data. The basic services that
form the foundation of the internet are e-mail, telnet and FTP. With internet we can easily
exchange electronic mail with friends and family anywhere in the world.
Telnet allows you to connect to a remote computer. We can access any of the public
services or tools and library databases at the remote site. FTP (File Transfer Protocol)
provides for transferring files from one computer to another across the internet.
Internet has many uses. For individuals, the most important uses of internet are e-mail and
surfing the Web. One can read the topics of interest like sports, a hobby, a country or any
place of interest.
E-mail:
The e-mail stands for electronic mail. One of the major features of computer networking is
that messages can be sent electronically to various terminals on the network. The messages
are sent very quickly and accurately. E-mail uses the concept of Storing and forwarding
messages. It saves a lot of money for the users. Here user registers his/her account with
one of the providers. The e-mail account normally contains username and the provider
Internet
Internet is a world-wide/global system of interconnected computer networks.
Internet uses the standard Internet Protocol (TCP/IP)
Every computer in internet is identified by a unique IP address.
IP Address is a unique set of numbers (such as 110.22.33.114) which identifies a
computer location.
A special computer DNS (Domain Name Server) is used to give name to the IP
Address so that user can locate a computer by a name.
For example, a DNS server will resolve a name http://www.tutorialspoint.com to a
particular IP address to uniquely identify the computer on which this website is
hosted.
Internet is accessible to every user all over the world.
Intranet
Intranet is system in which multiple PCs are networked to be connected to each other.
PCs in intranet are not available to the world outside of the intranet.
Usually each company or organization has their own Intranet network and
members/employees of that company can access the computers in their intranet.
Each computer in Intranet is also identified by a IP Address, which is unique among
the computers in that Intranet.
Hard Drive
Hard disk is used for storage purpose. Higher the capacity, more data you can save in
it.
Nowadays, computers are equipped with 500GB, which can be extended to 2TB.
Most hard drives in desktop operate at the standard performance speed of 7200RPM.
CPU
Frequency (GHz) - This determines speed of the processor. More the speed, better
the CPU.
Cores - Today's CPUs come with more than one core, which is like having more than
one CPU in the computer. Programs, which can take advantage of multi-core
environment, will run faster on such machines.
Brand - Intel or AMD. Both are equivalent. Intel is in lead.
Cache - Higher the L1, L2 cache, better the CPU performance.
Recommended - Intel Core i3 i3-3225 3.30 GHz Processor.
Input Devices
Following are few of the important input devices which are used in Computer Systems
Keyboard
Mouse
Joy Stick
Light pen
Track Ball
Scanner
Graphic Tablet
Microphone
Magnetic Ink Card
Reader (MICR)
Keyboard
Most common and very popular input device is keyboard. The keyboard helps in inputting
the data to the computer. The layout of the keyboard is like that of traditional typewriter,
although there are some additional keys provided for performing some additional
functions.
These keys include the letter keys (A-Z) and digits keys (0-9)
which are generally give same layout as that of typewriters.
3. Function Keys
2. Numeric Keypad
4. Control keys
5. Special Purpose Keys
Summary:
Computer network is defined as a interconnection of autonomous computers.
Computer networking enables us to connect computers to share data, application
software and hardware devices.
Networks allow sharing of information among various computers and permit users to
share files.
A LAN or local area network connects computers and peripherals in a limited area.
A MAN covers the city or town.
A Wide Area Network covers a large area.
The internet is a massive wide area network, connecting thousands of computer networks
around the world.
E-mail is a cost effective communication
Exercise
1. What is a computer network? What are the advantages of computer network?
2. Briefly explain the Local area network, Metropolitan area network and wide area
network.
3. What e-mail? How e-mail works?
4. What are the uses of Internet?
Summary:
A computer is an electronic device which takes information and process information
according to the program and produces the output.
A computer system has five basic functional units.
The Central Processing Unit is the brain of the computer.
The arithmetic-logic unit (ALU) is the unit of the computer that performs arithmetic
and logical operations on the data.
The control unit controls the overall activities of the components of the computer.
The memory unit is the unit where all the input data and results stored.
Stored program concept uses the memory unit to store both instruction or operation
code and data or operands.
NIC
Short for Network Interface Card, a NIC is also commonly referred to as an Ethernet
card and network adapter and is an expansion card that enables a computer to connect to
a network such as a home network or the Internet using an Ethernet cable. A Network
Interface Card (NIC) is a computer hardware component that allows a computer to connect
to a network. NICs may be used for both wired and wireless connections.
A NIC is also known as a Network Interface Controllers (NIC), Network Interface Controller
Card, expansion card, computer circuit board, network card or LAN card
Every computer on a network, both clients and servers, requires a network interface card
(or NIC) in order to access the network. A NIC is usually a separate adapter card that slides
Characteristics
Share Resources from one computer to another
Create files and store them in one computer, access those files from the other
computer(s) connected over the network
Connect a printer, scanner or a fax machine to one computer within the network and
let other computers of the network use the machines available over network.
Following is the list of hardwares required to set up a computer network:
Network Cables
Distributors
Router
Internal Network Cards
External Network Cards
Network Cables
Network cables are used to connect computers. The most commonly used cable are
Category 5 cable RJ-45.
Distributors
Each and every computer can be connected to another one via a serial port, but if we
need to connect many computers to produce a network, this serial connection will not
work. The solution is to use a central body to which other computers, printers,
scanners, etc., can be connected and then this body will manage or distribute network
traffic.
Router
A router is a type of device, which acts as the central point among computers and
other devices that are part of a network.
A router is equipped with holes called ports.
Computers and other devices are connected to a router using network cables.
Nowadays, router comes in wireless modes using which computers can be connected
without any physical cable.
USB cards are easy to use and connect via USB port.
Computer automatically detects USB card and can install the drivers required to
support the USB network card automatically.
Today most flash memory chips have selective erasure, allowing parts or sectors of the
flash memory to be erased. However any erasure still means that a significant section of the
chip has to be erased.
Flash memory history
Flash memory dates back to around 1980 when the concept was developed at Toshiba by
Dr. FujioMasuoka. It was then later presented at the 1984 IEEE International Electron
Devices Meeting, IEDM held in San Francisco, California.
The basic laboratory concept took a few years to develop into a product that could be
launched commercially. Intel introduced the first commercial chips onto the market in
1988 - these neither were NOR based types.
The NOR flash memories had relatively long erase and write times. Toshiba again
developed their technology further and were able to announce NAND technology at the
1987 IEDM. This technology, though, still needed further development to take it through to
commercial launch.
The advantage of NAND flash was that it had reduced erase and write times and it had a
greater storage density.
MEMORY FLASH
DISADVANTAGES
Non-volatile memory
Easily portable (e.g. USB memory
sticks)
Mechanically robust
MEMORY
NAND / NOR tradeoff: NAND Flash memories and NOR Flash memories can be used for
different applications. However some systems will use a combination of both types of Flash
memory. The NOR memory type is used as ROM and the NAND memory is partitioned with
a file system and used as a random access storage area.
Flash memory is a particularly important form of semiconductor memory. It is now widely
used and is possibly one of the most important forms of medium term storage. As
mentioned earlier Flash memory can be seen in a variety of forms and uses ranging from
Flash memory USB sticks to Compact Flash cards used for cameras. In addition to this many
other items of electronics can be seen using Flash memory ranging from mobile phones to
MP3 players and many more. In view of its current importance, Flash memory will be seen
in widespread use for many years to come.
We store and transfer all kinds of files on our computers -- digital photographs, music files,
word processing documents, PDFs and countless other forms of media. But sometimes your
computer's hard drive isn't exactly where you want your information. Whether you want to
make backup copies of files that live off of your systems or if you worry about your
security, portable storage devices that use a type of electronic memory called flash
memory may be the right solution.
Electronic memory comes in a variety of forms to serve a variety of purposes. Flash
memory is used for easy and fast information storage in computers, digital cameras and
home video game consoles. It is used more like a hard drive than as RAM. In fact, flash
memory is known as a solid state storage device, meaning there are no moving parts -everything is electronic instead of mechanical.
Here are a few examples of flash memory:
Your computer's BIOS chip
Compact Flash (most often found in digital cameras)
Smart Media (most often found in digital cameras)
Memory Stick (most often found in digital cameras)
PCMCIA Type I and Type II memory cards (used as solid-state disks in laptops)
Memory cards for video game consoles
There is still a problem with this type of flash memory wear levelling with blocks of
data that never get replaced. They remain with no additional wear.
The name for this type of wear leveling comes from the fact that only the dynamic
data, i.e. data that is changed, is recycled. The memory may last longer than one with
no wear leveling, but there will still be blocks of data that remain operable as a result
of low usage, long after the memory as a whole is inoperable as some areas have
exceeded the number of programme-erase cycles.
Static wear leveling: This form of wear leveling is the most sophisticated and
effective. Static wear leveling also uses a map to link the Logical Block Addresses to
physical memory addresses.
Static wear leveling works the same as dynamic wear leveling but with the addition
that blocks of static data, i.e. data that does not change, are periodically moved so that
these low usage cells are used by other data. By moving even static data periodically it
levels the usage and hence levels the wear across the whole memory.
The various forms of wear leveling ensure that the maximum life is achieved for a flash
memory. The wear leveling algorithms combined with improved semiconductor lifetimes,
means that flash memory is an effective form of solid state memory.
Introduction:
Flash memory or a flash RAM is a type of nonvolatile semiconductor memory device where
stored data exists even when memory device is not electrically powered. It's an improved
version of electrically erasable programmable read-only memory (EEPROM). The
difference between Flash Memory and EEPROM are, EEPROM erases and rewrite its
content one byte at a time or in other words, at byte level. Whereas Flash memory erases or
writes its data in entire blocks, which makes it a very fast memory compared to EEPROM.
Flash memory can't replace DRAM and SRAM because the speed at which the DRAM/SRAM
can access data and also their ability to address at byte level can't be matched by Flash.
The flash memory is also termed as Solid-state Storage Device (SSD) due to the absence of
moving parts in comparison to traditional computer hard disk drive.
NAND-flash occupies smaller chip area per cell. This maker NAND available in greater
storage densities and at lower costs per bit than NOR-flash. It also has up to ten times the
endurance of NOR-flash. NAND is more fit as storage media for large files including video
and audio. The USB thumb drives, SD cards and MMC cards are of NAND type.
NAND-flash does not provide a random-access external address bus so the data must be
read on a block-wise basis (also known as page access), where each block holds hundreds
to thousands of bits, resembling to a kind of sequential data access. This is one of the main
reasons why the NAND-flash is unsuitable to replace the ROM, because most of the
microprocessors and microcontrollers require byte-level random access.
A write operation in any type of flash device can only be performed on an empty or erased
unit. So in most cases write operation must be preceded by an erase operation. The erase
operation is fairly straightforward in the case of NAND-flash devices. But for a NOR-flash, it
is mandatory that all bytes in the target block should be written with zeros before they can
be erased.
The size of an erase-block in NOR-flash ranges from 64 to 128 Kbytes. Here a write/erase
operation can take up to 5 s. But the NAND-flash has erase blocks 8 to 32 Kbytes in size. So
it is obvious that the NAND performs the identical operation in a lesser time duration.
INOR-flash interface resembles closely to a SRAM memory interface, which has enough
address pins to map its entire media, allowing for easy access to every byte contained in it,
whereas the NAND-flash go for serially accessed complicated I/O mapped interface. Here
the same pins are used for control, address & data.
In traditional single-level cell flash devices, each cell stores only one bit of information.
Later, many developers have developed a new form of flash memory known as multi-level
cell flash that can store/hold more than one bits rather than a single bit in each memory
cell, thus doubling the capacity of memory.
QUIZ QUESTIONS
1) A Computer consists of --- units.
a) 3 b) 4 c) 5 d) 6
2) Keyboard is an example of ------ unit.
a) Memory b) Input c) Output d) ALU
3) ALU stands for -------
PART B
Print r1, r2
ELSE IF d < 0
r1 -b/ (2a)
r2 r/ (2a)
Print Roots are COMPLEX
Print r1 +i r2, r1 - i r2
ELSE
r1 -b/ (2a)
Print Roots are EQUAL
Print r1, r1
END IF
END IF
END IF.
Step 4. Stop
void main ( )
{
int a, b, c;
float d, x1, x2, r;
clrscr ( );
printf("Enter the three co-efficients:\n"); / * Accept three co-efficients * /
scanf("%d%d%d", &a, &b, &c);
if (a* b* c == 0)
/ * Check for zero co-efficients * /
{
printf("\n Invalid Input ");
}
else
{
d = b * b - 4 * a * c;
r=sqrt(fabs(d));
",x1,x2,x1,x2);
}
if (d > 0)
{
x1 = (-b +r) / (2.0*a);
x2 = (-b -r) / (2.0*a);
printf("\n The roots are real and distinct\n");
printf("\n The roots are \n 1) x1=%f\t\t \n 2) x2=%f",x1,x2);
}
else if (d == 0)
{
x1 = x2 = -b/(2.0*a);
printf("\n The roots are real and equal\n");
printf("\n The roots are: \n 1) x1=x2=%f",x1);
}
else
{
x1 = -b / (2.0 * a);
x2 =r / (2.0*a);
printf("\n The roots are real and imaginary\n");
printf("\n The roots are:\n 1) %f +i %f \t\t\n 2) %f i %f
}
getch( );
Sample Output
First Run
Enter the three co-efficients:
1 4
4
The roots are real and equal
The roots are:
X1=X2=2.0000
Second Run
Enter the three co-efficients:
1 -5
6
The roots are real and distinct
The roots are:
X1=3.0000
X2=2.0000
Third Run
Enter the three co-efficients:
2 3
4
The roots are real and imaginary
The roots are:
1) -0.750000 +i 1.198958
2) -0.750000 - i 1.198958
Fourth Run
Enter the three co-efficients:
1 0
5
Invalid Input
#include <conio.h>
void main( )
{
int n, rev=0, rem, num;
clrscr ( );
printf("Enter a number : ");
scanf("%d", &n);
num = n;
while(n != 0)
{
rem=n%10;
rev= rev*10+rem;
n = n / 10;
}
Printf(The reverse of %d is %d, num, rev);
if(num==rev)
printf("\n The given Number %d is Palindrome", num);
else
printf("\n The given Number %d is not Palindrome", num);
getch( );
Sample Output
First Run
Enter a number:
2018
1) Start
2) Read num
3) If num=0
print error
4) Otherwise for i=0 to num repeat step 5
i=i*j
break
end if
6) Print i as square root value
7) End if
8) Stop
//Program to find the square root of a number without using library function
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main( )
{
float n, temp=0.0, s;
clrscr ( );
printf("ENTER ANY NUMBER : ");
scanf("%f", &n);
s = n/2;
while (s != temp)
{
temp = s;
s = (n/s+s)/2;
}
printf("\nSQRT = %.3f, s");
printf(\nSQRT by built-in function = %.3f, sqrt(n));
getch ( );
return 0;
}
Sample Output
Run 1
ENTER ANY NUMBER: 4
SQRT = 2.000
SQRT by built-in function = 2.000
Run 2
ENTER ANY NUMBER: 2
SQRT = 1.414
SQRT by built-in function = 1.414
/* C program to check whether a year is leap year or not using if else statement.*/
#include <stdio.h>
int main( )
{
int year;
clrscr( );
printf("Enter a year: ");
scanf("%d",&year);
if(year%4 == 0 && year%100 != 0 || year % 400 = = 0)
{
printf("\n%d is a leap year.\n", year);
}
else
printf("\n%d is not a leap year.\n", year);
return 0;
}
Sample Output
Run1
Enter a year: 2000
2000 is a leap year
Run 2
Enter a year: 1900
1900 is not a leap year
Run 3
Enter a year: 2014
2014 is not a leap year
Stop
int main( )
{
int n, i;
float x, term, sum, degree;
clrscr( );
printf("\nEnter the value of limit\n");
scanf("%d", &n);
printf("Enter Degrees \n");
scanf("%f",°ree);
x = degree * PI/180;
sum = term = x;
for(i = 3; i<=n; i+=2)
{
term = -term*x*x/(i*(i-1));
sum = sum+term;
}
printf("sin(%f) = %f\n",degree, sum);
printf("Using Library Function \n");
printf("sin(%f) = %f\n", degree,sin(x));
getch( );
return 0;
}
Sample output
Enter the value of limit: 5
Enter degrees: 75
Sin (75) = 0.9766
Using Library Function
sin (75) = 0.9765
1. Start.
2. Read n.
3. FOR i0 to n-1 in steps of 1
Read integer numbers in array a [ ]
b[i]a[i]
END FOR.
4. FOR i0 to n-1 in steps of 1
FOR j0 to n-i in steps of 1
Check IF a[j] > a[j + 1]
temp= a[j]
a[j] = a[j + 1]
a[j+1] = temp
END IF
END FOR
END FOR
5. Print original array b[i]
FOR i0 to n-1 in steps of 1
Print b[i]
END FOR.
6. Print sorted array a[i]
FOR i0 to n-1 in steps of 1
Print a[i]
END FOR.
Flowchart
}
printf("\n");
}
printf("\n MATRIX C \n");
for(i = 0 ; i < m ; i++)
{
for(j = 0 ; j < q ; j++)
{
printf(" %d \t", c[i][j]); //print product matrix
}
printf("\n");
}
}
else
printf("Matrix A & B is not multipliable");
getch ( );
Sample Output
Run1
Enter the order of the matrix A :2 2
Enter the order of the matrix B :2 2
Enter the elements of matrix A
12
34
Enter the elements of matrix B
23
45
MATRIX A
12
34
MATRIX B
23
45
MATRIX C
10 13
22 29
Run 2
Enter the order of the matrix A: 2 3
Enter the order of the matrix B: 2 3
Matrix A & B is not multipliable
Run 2
Enter the number of names to read: 5
Enter the names in ascending order
Ajay
Biju
Chaya
Dhruv
Firoz
Enter the name to be searched: Sinchana
Name not found
int main ( )
{
char str1[50],str2[50];
clrscr( );
printf("Enter the source string: \n");
gets(str1);
strcopy(str1,str2);
printf("Destination string str2: \n");
puts(str2);
getch( );
return 0;
}
Output
Enter the source string:
Acharya Institute
Destination string str2:
Acharya Institute
Algorithm
break;
break;
break;
break;
break;
default: Cc++;
[end switch]
[end if statement]
6) i++;
[end step 3 while loop]
7) Output Vowels and Consonents
8) Stop
Flowchart
Algorithm
Algorithm to rotate value by n bits
1. IF x%2=0
right shift x by 1
ELSE
right shift x by 1 and add 32768 to it
2. Return
Run2
Enter the range
8 10
There are no prime numbers between the given ranges
Algorithm
Starting of fact ( )
If n==1 or n==0
Return 1
Otherwise
Return n * fact (n-1)
Flowchart
Start
Input n, r
Ncr= fact (n)/fact (n-r) * fact (r)
Output Ncr
Stop
#include<stdio.h>
#include<conio.h>
int fact (int n)
{
if(n==0||n==1)
return 1;
else
return(n*fact(n-1));
}
void main ( )
{
int n, r, ncr;
clrscr( );
printf ("enter the value of n & r\n");
scanf("%d%d", &n, &r);
ncr=fact(n)/fact(n-r)*fact(r);
Is
n=1 or 0
n==0 or n==1
return n*fact (n-1)
True
return 1
Sample Output
Enter the value of n & r
42
The binomial coefficient is 6
USN
USN1
USN2
.
.
.
Start
Is fp==NULL?
Usn.txt
Print contents of
Output.txt
Output.txt
Stop
USN
1AY14CS001
1AY14CS002
1AY14CS003
1AY14CS004
True
Output student
record
found = 1
I
Is
found=0
False
Stop
True
Sample Output
Enter the number of students
2
Enter the 1 student details
Enter the roll number
15
Enter the student name
Aruna
Enter the marks
24
Enter the grade
A
Enter the 2 student details
Enter the roll number
21
Enter the student name
Krishna
Enter the marks
22
Enter the grade
A
Student details are
Rollno
Name
Marks
Grade
14
Aruna
24
A
21
Krishna
22
A
Enter the student Name to print the marks: Aruna
Marks of the student is: 24
Algorithm
8. mean = sum /n
[end step 6 for loop]
9. ptr = a
10. for i =0 to n-1 do
11. sumstd += pow ((*ptr - mean), 2)
12. std = sqrt (sumstd / n)
[end step 10 for loop]
13. Output [Sum, Mean, Standard Deviation]
14. Stop
Flowchart
I
Input i, n
Mean = Sum / n
for i =0 to n-1 do
for i =0 to n-1 do
Sum = 0, Sumstd =0
A [I]
I
ptr = a
for i =0 to n-1 do
ptr = a
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main ( )
{
float a[20], sum=0, mean, *ptr, sumstd=0, std;
int i, n;
clrscr( );
printf("Enter the size of the array\n");
scanf("%d", &n);
printf("Enter the array elements\n");
for (i=0; i<n; i++)
scanf("%f", &a[i]); //read array elements
ptr=a;
for (i=0; i<n; i++)
{
sum=sum + (*ptr);
ptr++;
}
mean=sum/n;
ptr=a;
for(i=0;i<n;i++)
{
sumstd = sumstd + pow ((*ptr - mean), 2); //calculate standard deviation
ptr++;
}
std=sqrt(sumstd/n);
printf("sum=%.3f\n, mean=%.3f\n, standard deviation=%.3f\n", sum, mean, std);
getch( );
}
Sample Output
Enter the no of elements
5
Enter the array elements
12345
Sum=15.000
Mean=3.000
Standard deviation=1.414