Problem Solving Techniques Course Overview
Problem Solving Techniques Course Overview
Course Outcomes(Cos)
Bloom's
Taxonomy
CO Knowledge
Number Course Outcomes(Cos) Statement Level
Study the basic knowledge of Computers.
CO1 Analyze the programming languages KI
Study the data types and arithmetic operations.
Know about the algorithms.
CO2 Develop program using flow chart and pseudocode. K2
Determine the various operators.
Explain about the structures.
CO3 Illustrate the concept of Loops K2
Study about Numeric data and character-based data.
CO4 Analyze about Arrays. K3
Explain about DFD
Illustrate program modules.
CO5 Creating and reading Files K3
CO2 3 3 3 3 3
CO3 3 3 3 3 3
CO4 3 3 3 3 3
CO5 3 3 3 3 3
Syllabus
E-Content/
Unit Content HOURS Resources
Introduction: History, characteristics and
limitations of Computer. Hardware/Anatomy of
Computer: CPU, Memory, Secondary storage
devices, Input Devices and Output devices. Types
of Computers: PC, Workstation, Minicomputer,
Main frame and Supercomputer. Software: System
software and Application software. Programming
Languages: Machine language, Assembly
language, Highlevel language,4 GL and 5GL-
Features of good programming language.
Translators: Interpreters and Compilers.
I 15
Data: Data types, Input, Processing of data,
Arithmetic Operators, Hierarchy of operations and
Output. Different phases in Program Development
Cycle (PDC).Structured Programming: Algorithm:
Features of good algorithm, Benefits and
drawbacks of algorithm. Flowcharts: Advantages
and limitations of flowcharts, when to use
flowcharts, flowchart symbols and types of
flowcharts. Pseudocode: Writing a pseudocode.
Coding, documenting and testing a program:
Comment lines and types of errors. Program
II design: Modular Programming 15
Selection Structures: Relational and Logical
Operators - Selecting from Several Alternatives –
Applications of Selection Structures. Repetition
Structures: Counter Controlled Loops –Nested
Loops– Applications of Repetition Structures.
III 15
Data: Numeric Data and Character Based Data.
Arrays: One Dimensional Array - Two
Dimensional Arrays – Strings as Arrays of
Characters.
IV 15
Data Flow Diagrams: Definition, DFD symbols
and types of DFDs. Program Modules:
Subprograms-Value and Reference parameters-
Scope of a variable - Functions – Recursion. Files:
File Basics-Creating and reading a sequential file-
Modifying Sequential Files.
V 15
Total 75
Note:
Stewart Venit, ―Introduction to Programming: Concepts and Design‖,
Fourth Edition, 2010, Dream Tech Publishers.
Text Books 1
[Link]
[Link]
Reference
Books 1
[Link]
2
3 [Link]
Assignments
25 Marks
Seminar
A. A group of elements of same data type B. An array contains more than one element
14. ______ is a unique tag, usually a number identifies the file within the file system.
(OR)
What is a computer?
The word “computer” comes from the word “compute” which means to calculate.
So a computer is normally considered to be a calculating device that performs arithmetic
operations at enormous speed.
More accurately, a computer may be defined as a device that that operates upon
information or data.
Now a day’s more than 80 % of the work done by computers today is a non mathematical
or non- numerical nature.
Modern Definition of computers
A computer is an electronic device which is used to perform operation on raw data as per
instruction given by user.
All the Plugged with computer system( e.g. keyboard, mouse, printer,CPUetc) is called
hardware, the language , instruction, data are the called software.
Speed: A computer is a very fast device. The computer takes a fraction of seconds to
perform any operation. The speed of computer is measured in micro seconds (10-3),
Milliseconds (10-6), nanoseconds (10-9) and even Picoseconds (10-12).A powerful computer is
capable of performing about 3-4 million simple operations per second.
Accuracy: The accuracy of computer is very high and the degree of a particular computer
depends upon its design. But for a particular computer, each and every calculation is
performed with the same accuracy. Errors can occur in a computer but these are mainly due
to human rather than technological weakness.
Storage Capacity: Computers can store data and instruction with a lot of volume and very
high efficiency.
Diligence: unlike human being a computer is free from monotony, tiredness, luck of
concentration etc. and hence can work for hours together without creating any error. A
computer can perform the last calculation with exactly the same accuracy and seed as the
first one.
Automation: Once a Program is in the computer’s memory, CPU follows the instructions
until it meets the last instruction. Though the program concept many takes can be performed
simultaneously, some on foreground and some on background. Thus automation bring the
program execution fast
Reliability: Because, computer is an electronic device thus it perform all operations with
100 % accuracy and reliability. Reliability can affect only error prone by human mind.
Versatility: versatility is one of the most wonderful things about the computer. One moment
it can do any one operation and next moment if can perform any other operation. A computer
is capable of performing almost any task according to given instructions.
Limitation or Drawback of Computer
No I.Q. : Computer is not a magical device. It performs only those works which man can
does but the main difference is that computer can work those operations with very high
speed and reliable accuracy. It has no any intelligence quality or thinking power
No Feeling: Because computer is only a machine, it has no feeling like human being. It has
no brain for thinking as man can does. Man had successes to make computer memory be
different inventions of technology but he couldn’t make heart.
Data Machine Readable: Computer data is read by machine, meaning data obtained from
the computer can be read by the computer itself.
It required power to operate.
Problem may occur due to system breakdown.
Hardware
Hardware is the physical components of a computer that includes all mechanical,
electrical, electronic and magnetic parts attached to it.
A computer consists of the following major hardware components:
A brief description of the most common hardware found in a personal computer is given in the
next few sections.
Input devices
The data and instructions are typed, submitted, or transmitted to a computer through input
devices.
Input devices are electronic or electro-mechanical equipment that provide a means of
communicating with the computer system for feeding input data and instructions. Most
common input devices are briefly described below.
Keyboard
Keyboard is like a type-writer. A keyboard, normally, consists of 104 keys. These keys
are classified into different categories which are briefly described below.
Character keys
These keys include letters, numbers, and punctuation marks. On pressing any character
key, the corresponding character is displayed on the screen.
Function keys
There are 12 functional keys above the key board which are used to perform certain
functions depending on the operating system or the software currently being executed.
These keys are placed at the top of the key board and can easily be identified with the
letter F followed by a number ranging from 1 to 12.
Control keys
Alt, Ctrl, Shift, Insert, Delete, Home, End, PgUp, PgDn, Esc and Arrow keys are control
keys.
Navigation keys
These include four arrows, Page Up and Page Down, Home and End. These keys are
normally used to navigate around a document or screen.
Toggle keys
Scroll Lock, Num lock, Caps Lock are three toggle keys. The toggle state is indicated by
three LEDs at the right-top side of the keyboard.
For example, on pressing caps lock, letters typed by the user will appear in upper case.
On pressing again, letters are typed on the screen in lower case.
Miscellaneous keys
These keys include Insert, delete, escape, print Screen etc. The keys on the keyboard are
placed in a series of rows and columns called the key matrix. Each key holds a position
with respect to a row and column.
When a key is pressed, the key switch in that position closes a circuit, sending a signal to
the circuit board inside the keyboard. The keyboard controller uses the x and y
coordinates of the matrix position to determine which key was pressed, thereby
determining what code is transmitted to the computer by the keyboard.
Mouse
A mouse is the pointing device attached to a computer. It is used to move the cursor
around the screen and to point to an object (such as icon, menu, command button etc.) on
the computer video screen for the purpose of selecting or activating objects on graphical
interface provided by the operating system or the software currently being executed and
executing various tasks.
It has two or three buttons for clicking. The mouse tracks the motion of the mouse pointer
and senses the clicks and sends them to the computer so it can respond appropriately. The
mouse can be connected to the system either through a USB connector or wirelessly
through infrared radiation. A wireless mouse needs to be powered through batteries.
Scanner
A scanner is a device that captures pictures or documents so that they can be stored in
storage devices, seen on the video screen, modified suitably, transported to other
computers, or printed on a printer. A personal computer with a scanner and printer can
function as a photocopier.
Output devices
Output devices mirror the input data, or show the output results of the operations on the
input data or print the data. The most common output device is monitor or visual display
unit. The printer is used to print the result.
A hard copy refers to a printout showing the information. On the other hand soft copy
means information stored on a storage device.
Monitor
Computer display devices are commonly known as Visual Display Unit (VDU) or
monitor. It operates on a principle similar to that of a normal television set. Various
technologies have been used for computer monitors.
They are also of different sizes. CRT (Cathode-ray tube) and LCD (liquid crystal
display) monitors are the two common types which are widely used. The CRT is
composed of a vacuum glass tube which is narrower at one end. One electron gun is
placed at this end which fires electrons.
The electron gun is made up of cathode (negatively charged) and one anode (positively
charged). On the other side it has a wide screen, coded with phosphor.
The beam of electron strikes on the surface of screen and produces an image by photo
luminance process. There is some vertical and horizontal coil to deflect the electron beam
in any position of the screen. An image is formed by constantly scanning the screen.
To send an image to the screen, the computer first assembles it in a memory area called a
video buffer. The graphics are stored as an array of memory locations that represent the
colors of the individual screen dots, or pixels.
The video card then sends this data through a Digital To Analog Converter (DAC), which
converts the data to a series of voltage levels that are fed to the monitor. CRT monitors
are too bulky and consume high power. Apart from these, users are very much concerned
about potentially damaging non-ionizing radiation from CRT monitor.
Printer
The printer is a device that prints any data, report, document, picture, diagrams, etc.
Printers are categorized based on the physical contact of the print head with the paper to
produce a text or an image. An impact printer is one where the print head will be in
physical contact with the paper. In a non–impact printer, on the other hand the print head
will have no physical contact with the paper.
The Dot matrix printer is considered as an Impact printer and Laser printer is considered as
Non-impact printer. In a dot matrix printer, the printer head physically ‘hits’ the paper
through the ribbon which makes the speed of the printer relatively slow. The printer head
consist of some two dimensional array of dot called ‘dot matrix’. Every time when
it strikes the paper through ribbon its dots are arranged according to the character which is
going to be printed. The ink in the ribbon falls on the surface of the paper and thus the
character get printed. In inkjet printer, instead of a ribbon one ink cartridge holds the ink in
it. They are placed above the inkjet head.
The printing head takes some ink from the cartridge and spreads it on the surface of the
paper by the jet head. This ink is electrically charged. An electric field is created near the
paper surface. Thus the small drops of ink are arranged in the surface according to the
character it prints. These printers are fast and capable of printing good quality graphics.
The laser printer uses a laser beam to create the image.
Central processing unit (CPU)
Central Processing Unit or CPU can be thought of as the brain of the computer. Most of
the processing takes place in CPU. During processing, it locates and executes the program
instructions. It also fetches data from memory and input/output devices and sends data
back.
Physically, it is an integrated circuit (IC) silicon chip, mounted on a small square plastic
slab, surrounded by metal pins. In the world of personal computers, the term
microprocessor and CPU are used interchangeably. It is more accurate to describe it as a
CPU on a chip because it contains the circuitry that performs processing. The CPU itself
can be divided into different functional units which are described below-
Registers
These are high-speed storage devices. In most CPUs, some registers are reserved for
special purposes. For example, the Instruction Register (IR) holds the current instruction
being executed. The Program Counter (PC) is a register that holds the address of the next
instruction to be executed. In addition to such and other special-purpose registers, it also
contains a set of general-purpose registers that are used for temporary storage of data
values as needed during processing.
Arithmetic logic unit (ALU)
It is the part of the CPU that performs arithmetic operations, such as addition and
subtraction as well as logical operations, such as comparing two numbers to see if they
are the equal or greater or less.
Control unit (CU)
The control unit coordinates the processing by controlling the transfer of data and
instructions between main memory and the registers in the CPU. It also coordinates the
execution of the arithmetic logic unit (ALU) to perform operations on data stored in
particular registers. It consists of an instruction decoding circuit that interprets what action
should be performed.
a control and timing circuit directs all the other parts of the computer by producing the
respective control signals.
Nowadays, a high-speed memory, called cache memory, is embedded with the CPU chip.
This improves the computer performance by minimizing the processor need to read data
from the slow main memory.
The CPU’s processing power is measured in terms of the number of instructions that it
can execute per unit time. Every computer comprises of an internal clock, which emits
electronic pulses at a constant rate.
These pulses are used to control and synchronize the pace of operations. Each pulse is
called a clock cycle which resembles a rectangular wave with a rising half of the signal
and a falling half. In other words, a full clock cycle is the amount of time that elapses
between pulses of the oscillating signal.
Each instruction takes one or more clock cycles to execute. The higher the clock speed,
the more instructions are executed in a given period of time. Hertz (Hz) is the basic unit of
computer clock frequency which is equal to one cycle per second.
CPU speed has been improved continuously. It is typically measured in megahertz (MHz)
or gigahertz (GHz). One megahertz is equal to one million cycles per second, while one
gigahertz equals one billion cycles per second.
Nowadays, multiple processors are embedded together on a single integrated-circuit chip,
known as multi-core processor e.g. a dual-core processor has two CPUs and a quad core
processor has four CPUs.
Memory unit
Components such as the input device, output device, and CPU are not sufficient for the
working of a computer. A storage area is needed in a computer to store instructions and
data, either temporarily or permanently, so that subsequent retrieval of the instructions and
data can be possible on demand.
Data are stored in memory as binary digits, called bits. Data of various types, such as
numbers, characters, are encoded as series of bits and stored in consecutive memory
locations.
Each memory location comprises of a single byte which is equal to eight bits and has a
unique address so that the contents of the desired memory locations can be accessed
independently by referring to its’ address.
A single data item is stored in one or more consecutive bytes of memory. The address of
the first byte is used as the address of the entire memory location. CPU uses registers
exclusively to store and manipulate data and instructions during the processing.
Apart from registers, there are mainly two types of memory that are used in a computer
system. One is called primary memory and the other secondary memory.
Primary memory
Primary memory is the area where data and programs are stored while the program is
being executed along with the data. This memory space, also known as main memory,
forms the working area of the program.
This memory is accessed directly by the processor. A memory module consists of a large
bank of flip-flops arranged together with data traffic control circuitry such that data can be
stored or read out on or from a set of flip-flops.
A flip-flop can store a binary digit. These flip-flops are grouped to form a unit memory of
fixed length and each of which is identified by a sequence number known as a memory
address. These type are called Random Access Memory, or RAM, where any location can
be accessed directly, and its stored contents get destroyed the moment power to this
module is switched off.
Hence, these are volatile in nature. Primary memory devices are expensive. They are
limited in size, consume very low power, and are faster as compared to secondary
memory devices. There is another kind of primary memory increasingly being used in
modern computers. It is called cache memory (pronounced as “cash”).
It is a type of high speed memory that allows the processor to access data more rapidly
than from memory located elsewhere on the system.
It stores or caches some of the contents of the main memory that is currently in use by the
processor. It takes a fraction of the time, compared to main memory, to access cache
memory.
The management of data stored in the cache memory ensures that for 20 per cent of the
total time, during which the cache is searched, the data needed is found to be stored in
cache. As a result the performance of the computer improves in terms of speed of
processing.
Secondary memory
Secondary memory provides large, non-volatile, and inexpensive storage for programs
and data. However, the access time in secondary memory is much larger than in primary
memory.
Secondary storage permits the storage of computer instructions and data for long periods
of time. Moreover, secondary memory, which is also known as auxiliary memory, stores a
huge number of data bytes at a lesser cost than primary memory devices.
Memory operations
There are some operations common to both primary and secondary memory devices.
These are as follows.
[Link] During this operation, data is retrieved from memory.
[Link] In this operation, data is stored in the memory. Using read and write operations, many
other memoryrelated functions such as copy and delete are carried out.
Unit of memory
The memory’s interface circuit is designed to logically access a byte or a multiple of a
byte of data from the memory during each access.
The smallest block of memory is considered to be a byte, which comprises eight bits.
The total memory space is measured in terms of bytes. Thus, the unit of memory is a
byte.
The capacity of memory is the maximum amount of information it is capable of storing.
Since the unit of memory is a byte, the memory’s capacity is expressed in number of
bytes.
Some units used to express the memory capacity are as follows:
The size of the register is one of the important considerations in determining the
processing capabilities of the CPU.
Word size refers to the number of bits that a CPU can manipulate at one time. Word size
is based on the size of registers in the ALU and the capacity of circuits that lead to those
registers.
A processor with a 32-bit word size, for example, has 32- bit registers, processes 32 bits
at a time, and is referred to as a 32-bit processor.
Processor’s word size is a factor that leads to increased computer performance. Today’s
personal computers typically contain 32-bit or 64-bit processors.
Memory hierarchy
The various types of memory used in a computer system differ in speed, cost, size, and volatility
(permanence of storage). They can be organized in a hierarchy. The memory hierarchy in the
computer system is depicted as:
Registers
Cache
Main Memory
Secondary Memory
Types of Computers
1. Personal computers
2. Mini computers
3. Mainframe computers
4. Super computers
Microcomputer
Microcomputers are nothing but personal computers. These are single-chip systems. These
are useful for personal use and can perform all the basic functions of the computer.
Microcomputers require very little space and are comparatively inexpensive.
Such computers have the most minimalistic requirement in terms of I/O devices. And have
all the circuitry mounted on a single PCB. For example tablets, I pads, smartwatches,
laptops, desktops
Minicomputer
Standing in between a microcomputer and a mainframe computer is the minicomputer.
These computers are useful if people around 5 to 300. Those who want to operate the
system at the same time. You can see such computers at the billing counters of malls or
large institutions.
Mainframe
Mainframe computers are useful when a large number of people are involved. Like in the
health care or retail sector who want to access data simultaneously. These computers
process large amounts of data.
In addition, mainframe computers have evolved a lot over the years in terms of speed, size,
and efficiency. These computers are just below the supercomputers. And sometimes are
even more useful than a supercomputer. Examples – IBM z Series, System z9, etc.
Supercomputers
The biggest and fastest computers are supercomputers. Such computers can process
trillions of functions within a few seconds. We generally use MPIS ( Million Instructions
Per Second) to measure their performance.
These computers are specifically designed for scientific applications such as –
1. Encryption decryption of passwords
2. Weather forecasting
3. Testing of nuclear weapons
4. Scientific research of earth and other planetary systems, etc.
Software
Computer Software is a sort of program that allows clients to work on different
assignments or use them to work on their System.
It tells the working and responsibilities of the System. Basically, Software is a set of
instructions or commands that tells a user how to do and what to do.
Types of Software
1. System Software
2. Application Software
1. System Software
System Software is the type of software that is the interface between application
software and the system. Low-level languages are used to write the system software.
System Software maintains the system resources and gives the path for application
software to run. An important thing is that without system software, the system can
not run. It is general-purpose software.
Memory Management
Processor Management
File Management
Security
Error-detecting Aids
Scheduling
Operating System: Operating System is the main part of the Computer System. It has the
responsibility of managing all the resources such as CPU, Printer, Hard Disk, etc. It also
provides services to many other Computers Softwares. Examples of Operating Systems are
Linux, Apple, macOS, Microsoft Windows, etc.
Device Driver: A Device Driver is a program or software that helps to perform its functions
by controlling the device. You first have to install a driver for running the program.
2. Application Software
Application Software is the type of software that runs as per user request. It runs on the
platform which is provided by system software. High-level languages are used to write
the application software.
It’s a specific purpose software. The main difference between System Software and
Application Software is that without system software, the system can not run on the
other hand without application software, the Low-level maintenance system always runs.
1. General Purpose Software: This Application Software is used to perform tasks that are used
for a variety of tasks, just not limited to a specific task only. For Example, MS Word, MS
Excel, etc.
2. Customized Software: It is used to perform tasks that are designed for specific
organizations. For Example, Railway Reservation System, Airline Reservation System, etc.
3. Utility Software: It is used to support the architecture of the Computer. It is designed for
optimizing and maintaining the system and also taking care of its requirements.
Programming languages
Over the years, computer languages have been evolved from Low-Level to High-Level
Languages. In the earliest days of computers, only Binary Language was used to write
programs. The computer languages are classified as follows:
o Low level language
o Middle level language
o High level language
Low-Level language is the only language which can be understood by the computer. Low-
level language is also known as Machine Language.
The machine language contains only two symbols 1 & 0. All the instructions of machine
language are written in the form of binary numbers 1's & 0's. A computer can directly
understand the machine language.
Middle-level language is a computer language in which the instructions are created using
symbols such as letters, digits and special characters.
Assembly language is an example of middle-level language. In assembly language, we
use predefined words called mnemonics.
Binary code instructions in low-level language are replaced with mnemonics and operands
in middle-level language. But the computer cannot understand mnemonics, so we use a
translator called Assembler to translate mnemonics into machine language.
Assembler is a translator which takes assembly code as input and produces machine code
as output.
That means, the computer cannot understand middle-level language, so it needs to be
translated into a low-level language to make it understandable by the computer. Assembler
is used to translate middle-level language into low-level language.
High-level language
High-level language is a computer language which can be understood by the users. The
high-level language is very similar to human languages and has a set of grammar rules that
are used to make instructions more easily.
Every high-level language has a set of predefined words known as Keywords and a set of
rules known as Syntax to create instructions. The high-level language is easier to
understand for the users but the computer can not understand it.
High-level language needs to be converted into the low-level language to make it
understandable by the computer. We use Compiler or interpreter to convert high-level
language to low-level language.
Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-level
languages. All these programming languages use human-understandable language like
English to write program instructions.
These instructions are converted to low-level language by the compiler or interperter so
that it can be understood by the computer.
Features of 4GL:
PROLOG
Prolog stands for Programming with Logic. It is a high-level programming
language. It is also a logical and declarative fifth-generation programming
language like Mercury.
It plays a major role in the field of AI (Artificial Intelligence). It can easily
find whether any statements are following logic or not. The programs written
in Prolog are often smaller easier to understand and maintain.
Backtracking is one of the features of the Prolog programming language. It
supports recursion. It is sometimes called rule-based language. In prolog,
logics are indicated as relations.
It may be a choice in the rapid prototyping process. It works with Mac OS,
Linux and Windows.
OPS5
OPS5 stands for the Official Production System. It was developed by Charles
Forgey in 1970. It is also a fifth-generation programming language. It is a
rule-based production system programming language.
A rule consists of pre-conditions and a resulting action. The system checks
into memory for the rules whose pre-condition is verified. If verified, then the
action of the satisfied rule is executed. It is used in artificial intelligence,
expert systems.
It uses a forward chaining inference engine. The programs are executed by
scanning working memory elements if the pre-condition rule verified in the
production memory.
Software programming tools
Translators
The most general term for a software code converting tool is “translator.” A
translator, in software programming terms, is a generic term that could refer
to a compiler, assembler, or interpreter; anything that converts higher level
code into another high-level code (e.g., Basic, C++, Fortran, Java) or lower-
level (i.e., a language that the processor can understand), such as assembly
language or machine code.
If you don’t know what the tool actually does other than that it accomplishes
some level of code conversion to a specific target language, then you can
safely call it a translator.
Compilers
Interpreters
Assemblers
ONE MARKS
[Link] system is used in which generation of computer for the first time?
A] First Generation
B] Second Generation
C] Third Generation
D] Fourth Generation
B] A memory
A]Disk unit
B]Control unit
3]ALU
4]Modem
A]Five
B]Three
C]Two
D]Four
E]None of the above
A]Disk unit
B]Control unit
C]ALU
D]Modem
[Link] of the following devices is widely used for playing games on the
computer?
A]scanner
B]touchpad
C]keyboard
D]joystick
A. 2
B. 3
C. 4
D. 5
B. Control Unit
C. Storage Unit
[Link]
B. FALSE
[Link]
[Link]
[Link]-conductor
[Link] tube
[Link]
[Link]
[Link] memory
[Link] card
[Link]
[Link]
[Link]
[Link] ROM
42.C is a ___.
A. Low level language
B. High level language
C. Medium level language
D. None of the above
[Link] is a compiler?
A. system program that converts instructions to machine language
B. system program that converts machine language to high-level language
C. system program that writes instructions to perform
D. None of the mentioned
[Link] of computer?
[Link] of Computers?
[Link] is software? and explain its types?
[Link] programming Languages?
[Link] is Computer ? types of Computers?
TEN MARKS
UNIT II
Data types
Each variable in C has an associated data type. It specifies the type of data
that the variable can store like integer, character, floating, double, etc.
Each data type requires different amounts of memory and has some specific
operations which can be performed over it. The data type is a collection of
data with values having fixed values, meaning as well as its characteristics.
Types Description
Primitive Data Primitive data types are the most basic data types that are
Types Description
User Defined
The user-defined data types are defined by the user himself.
Data Types
The data types that are derived from the primitive or built-
Derived Types
in datatypes are referred to as Derived Data Types.
Input
Program
// Create an integer variable that will store the number we get from the user
int myNum;
The Scanf() function takes two arguments: the format specifier of the
variable (%d in the example above) and the reference operator (&mynum),
which stores the memory address of the variable.
Multiple Inputs
The scanf() function also allow multiple inputs (an integer and a character in
the following example):
When working with strings, we often use the fgets() function to read a line of
text. Note that you must include the following arguments: the name of the
string variable, sizeof(string_name), and stdin:
Program
char fullName[30];
Use the scanf() function to get a single word as input, and use fgets() for
multiple words.
Data processing
Collection, manipulation, and processing collected data for the required use is
known as data processing. It is a technique normally performed by a computer; the
process includes retrieving, transforming, or classification of information.
However, the processing of data largely depends on the following −
The volume of data that need to be processed
The complexity of data processing operations
Capacity and inbuilt technology of respective computer system
Technical skills
Time constraints
Methods of Data Processing
Let us now discuss the different methods of data processing.
Single user programming
Multiple programming
Real-time processing
On-line processing
Time sharing processing
Distributed processing
Multiple Programming
This technique provides facility to store and execute more than one
program in the Central Processing Unit (CPU) simultaneously. Further,
the multiple programming technique increases the overall working
efficiency of the respective computer.
Real-time Processing
This technique facilitates the user to have direct contact with the computer
system. This technique eases data processing. This technique is also
known as the direct mode or the interactive mode technique and is
developed exclusively to perform one task. It is a sort of online
processing, which always remains under execution.
On-line Processing
This technique facilitates the entry and execution of data directly; so, it
does not store or accumulate first and then process. The technique is
developed in such a way that reduces the data entry errors, as it validates
data at various points and also ensures that only corrected data is entered.
This technique is widely used for online applications
Time-sharing Processing
This is another form of online data processing that facilitates several users
to share the resources of an online computer system. This technique is
adopted when results are needed swiftly. Moreover, as the name suggests,
this system is time based.
Following are some of the major advantages of time-sharing processing −
Several users can be served simultaneously
All the users have almost equal amount of processing time
There is possibility of interaction with the running programs
Distributed Processing
This is a specialized data processing technique in which various computers
(which are located remotely) remain interconnected with a single host
computer making a network of computer.
Arithmetic operator
Arithmetic Operators are the type of operators in C that are used to
perform mathematical operations in a C program. They can be used in
programs to define expressions and mathematical formulas.
What are C Arithmetic Operators?
The C arithmetic operators are the symbols that are used to perform
mathematical operations on operands. There are a total of 9 arithmetic
operators in C to provide the basic arithmetic operations such as addition,
subtraction, multiplication, etc.
Types of Arithmetic Operators in C
Name of the
Operator Operator Arithmetic Operation Syntax
operand.
Unary Plus
+ Returns the value of its operand. +h
Operator
Increment Operator in C
The ‘++’ operator is used to increment the value of an integer. It can be used
in two ways:
1. Pre-Increment
When placed before the variable name (also called the pre-
increment operator), its value is incremented instantly. Consider the
example:
a = ++x;
This example can be expanded to
a = (x = x + 1);
2. Post Increment
When it is placed after the variable name (also called post-
increment operator), its value is preserved temporarily until the execution of
this statement and it gets updated before the execution of the next statement.
For example:
a = x++;
It can be expanded to
a = x;
x = x + 1;
Decrement Operator in C
The ‘–‘ operator is used to decrement the value of an integer. Just like the
increment operator, the decrement operator can also be used in two ways:
1. Pre-Decrement
When placed before the variable name (also called the pre-
decrement operator), its value is decremented instantly. For example, – – x.
2. Post Decrement
When it is placed after the variable name (also called post-
decrement operator), its value is preserved temporarily until the execution
of this statement and it gets updated before the execution of the next
statement. For example, x – –.
Hierarchy of Operations
Problem Definition
Here, we define the problem statement and decide the boundaries of the
problem.
In this phase, we need to understand what is the problem statement, what is
our requirement and what is the output of the problem solution. All these are
included in the first phase of program development life cycle.
Problem Analysis
Here, we determine the requirements like variables, functions, etc. to solve
the problem. It means that we gather the required resources to solve the
problem, which are defined in the problem definition phase. Here, we also
determine the bounds of the solution.
Algorithm Development
Here, we develop a step-by-step procedure that is used to solve the problem
by using the specification given in the previous phase. It is very important
phase for the program development. We write the solution in step-by-step
statements.
Coding & Documentation
Here, we use a programming language to write or implement the actual
programming instructions for the steps defined in the previous phase. We
construct the actual program in this phase. We write the program to solve the
given problem by using the programming languages like C, C++, Java, etc.
Testing & Debugging
In this phase, we check whether the written code in the previous step is
solving the specified problem or not. This means, we try to test the program
whether it is solving the problem for various input data values or not. We
also test if it is providing the desired output or not.
Maintenance
In this phase, we make the enhancements. Therefore, the solution is used by
the end-user. If the user gets any problem or wants any enhancement, then
we need to repeat all these phases from the starting, so that the encountered
problem is solved or enhancement is added.
Structured programming
What is an Algorithm?
Advantages of Algorithms
Disadvantages of Algorithms
Flow chart
Advantages Of Flowchart
Disadvantages Of Flowchart
The flowchart is a waste of time and slows down the process of software
development.
The flowchart is quite costly to produce and difficult to use and manage.
Flowcharts are not meant for man to computer communication.
Sometimes the Complex logic of the program logic is quite complicated to
draw out on by using different defined shapes. In that case, the flowchart
becomes complex and clumsy. This will become a pain for the user,
resulting in a waste of time and money trying to correct the problem.
If you need to modify or alternate the process then it will be very hard to
do in the flowchart. Because either you will have to erase the end of the
flowchart or start.
When to Use a Flowchart
To develop understanding of how a process is done.
To study a process for improvement.
To communicate to others how a process is done.
When better communication is needed between people involved with
the same process.
To document a process.
When planning a project.
4 Basic Flowchart Symbols for Creating a Flowchart
The Oval. An End or Beginning While Creating a Flowchart. The oval,
or terminator, is used to represent the start and end of a process. ...
The Rectangle. A Step in the Flowcharting Process. ...
The Arrow. Indicate Directional Flow. ...
The Diamond. Indicate a Decision.
Pseudo code
1. The way the if-else, for, while loops are indented in a program, indent the
statements likewise, as it helps to comprehend the decision control and
execution mechanism. They also improve the readability to a great extent.
Example:
if "1"
print response
"I am case 1"
if "2"
print response
"I am case 2"
1. Use appropriate naming conventions. The human tendency follows the approach
to follow what we see.
2. If a programmer goes through a pseudo code, his approach will be the same as
per it, so the naming must be simple and distinct.
3. Use appropriate sentence casings, such as CamelCase for methods, upper case
for constants and lower case for variables.
4. Elaborate everything which is going to happen in the actual code. Don’t make
the pseudo code abstract.
5. Use standard programming structures such as ‘if-then’, ‘for’, ‘while’, ‘cases’ the
way we use it in programming.
6. Check whether all the sections of a pseudo code is complete, finite and clear to
understand and comprehend.
7. Don’t write the pseudo code in a complete programmatic manner. It is necessary
to be simple to understand even for a layman or client, hence don’t incorporate
too many technical terms.
CODING
Int n = 10
for( i=0;i<n;i++)
printf(n);
The above source code is converted into a pseudo-code to understand in a
better way.
The value ten is assigned to the variable n.
For value = zero to less than a number.
Display the numbers.
Documentation Process
Pseudocode
Develop user documentation (API docs) and technical docs (for other coders
and administrators).
Testing
Pseudo code is also useful when preparing test data, since the cases that
should be covered by tests are clearly displayed in the conditions.
It will also be easy to sum up the results of testing, which in most cases
includes communication with other team members. Using pseudocode, you
can quickly and easily describe problem areas, the incorrect operation of
which was revealed by testing using pseudocode.
o it is visual;
o It’s fast.
Of course, the use of pseudocode is not justified and possible in all cases.
This is not a universal tool, but often it saves a lot of effort and time.
Comment line
The comments in C are human-readable explanations or notes in the
source code of a C program. A comment makes the program easier to
read and understand.
These are the statements that are not executed by the compiler or an
interpreter.
It is considered to be a good practice to document our code using
comments.
When and Why to use Comments in C programming?
A person reading a large code will be bemused if comments are not
provided about details of the program.
C Comments are a way to make a code more readable by providing
more descriptions.
C Comments can include a description of an algorithm to make code
understandable.
C Comments can be used to prevent the execution of some parts of
the code.
Types of comments in C
In C there are two types of comments in C language:
Single-line comment
Multi-line comment
1. Single-line Comment in C
A single-line comment in C starts with ( // ) double forward slash. It
extends till the end of the line and we don’t need to specify its end.
2. Multi-line Comment in C
The Multi-line comment in C starts with a forward slash and asterisk
( /* ) and ends with an asterisk and forward slash ( */ ). Any text
between /* and */ is treated as a comment and is ignored by the
compiler.
It can apply comments to multiple lines in the program.
TYPES OF ERRORS
Here we will see different types of errors using a C program. In any
programming language errors are common. If we miss any syntax like
parenthesis or semicolon then we get syntax errors. Apart from this we also
get run time errors during the execution of code.
3. Logical Errors
Even if the syntax and other factors are correct, we may not get the
desired results due to logical issues. These are referred to as logical
errors. We sometimes put a semicolon after a loop, which is
syntactically correct but results in one blank loop. In that case, it will
display the desired output.
Example: In the below example, the for loop iterates 5 times but the output
will be displayed only one time due to the semicolon at the end of for loop.
This kind of error is called a logical error.
4. Linker Errors
When the program is successfully compiled and attempting to link the
different object files with the main object file, errors will occur. When
this error occurs, the executable is not generated. This could be due to
incorrect function prototyping, an incorrect header file, or other
factors. If main () is written as Main (), a linked error will be
generated.
5. Semantic Errors
When a sentence is syntactically correct but has no meaning, semantic
errors occur. This is similar to grammatical errors. If an expression is
entered on the left side of the assignment operator, a semantic error
may occur.
Program Design
Program design includes planning for the learning environment and
experience. through conceptualizing change and selecting program
activities to bring about desired results. Program design fits into the
“Conceptualize Change” and “Design” sections of Extension's
Framework for Ongoing Program Development.
Overview
Modular programming
o Libraries in projects
o Function in the files
o Files in the libraries or repositories
Modularity is all about making blocks, and each block is made with the help
of other blocks. Every block in itself is solid and testable and can be stacked
together to create an entire application. Therefore, thinking about the concept
of modularity is also like building the whole architecture of the application.
Module
o There is a need for extra time and budget for a product in modular
programming.
o It is a challenging task to combine all the modules.
o Careful documentation is required so that other program modules are not
affected.
o Some modules may partly repeat the task performed by other modules.
Hence, Modular programs need more memory space and extra time for
execution.
o Integrating various modules into a single program may not be a task because
different people working on the design of different modules may not have the
same style.
o It reduces the program's efficiency because testing and debugging are time-
consuming, where each function contains a thousand lines of code.
ONE MARKS
a) I/O
b) Flow
c) Terminal
d) Decision
a) Decision
b) Initiation
c) Initialization
d) I/O
19. A box that can represent two different conditions.
a) Rectangle
b) Diamond
c) Circle
d) Parallelogram
FIVE MARKS
UNIT III
Selection Structure
Also known as a conditional structure, a selection
structure is a programming feature that performs
different processes based on whether a boolean
condition is true or false. Selection
structures use relational operators to test
conditions.
There are different types of selection
structures that can be used to achieve different
outcomes.
If you want your program to do something if a condition is true, but do
nothing if that condition is false, then you should use an if-
end structure.
If you want your program to do something if a condition is true and do
something different if it is false, then you should use an if-
else structure.
If you want to test multiple conditions, then you can include
an elseif structure within an if-end or if-else structure.
Contents
1. Selection Structure Types
1.1 if-end
1.2 if-else
1.3 elseif
Selection Structure Types
To get a better idea of how selection structures work, the following three
examples demonstrate how if-end, if-else, and elseif structures can be used to
test if a variable is above or below a certain valueor values.
if-end
If-end selection structures are used when only one boolean condition is
necessary. In if-end structures, a process will be only be performed if the
boolean condition is true.
For example, if we wanted to know the number of days from a data set where
the daily high temperature was above 80 degrees, a programmer could use an
if-end statement. The following screenshot shows this example in MATLAB.
When day is above 80, the boolean condition is true and the variable
NumAbove80 increases by 1.
NOTE: This is a simplified example. This code will not operate by itself. For
full instructions on creating an if-end structure in MATLAB go to the if-
end page.
if-else
If-else selection structures are used when only one boolean condition is
necessary. In if-else structures, a specific action will be performed if the
boolean condition is true and another action, if the condition is false.
For example, if we wanted to know the number of days from a data set where
the daily high temperature was above and below 80 degrees, a programmer
could use an if-else statement. The following screenshot shows this example
in MATLAB.
When day is above 80, the boolean condition is true and the variable
NumAbove80 increases by 1. However, when day is not above 80, the
boolean condition is false and the variable NumBelow 80 increases by 1. (In
this case, NumBelow80 is actually the number of days less than or equal to
80.)
NOTE: This is a simplified example. This code will not operate by itself. For
full instructions on creating an if-else structure in MATLAB go to the if-
else page.
elseif
else if structures are a way to combine multiple boolean conditions into a
single selection structure. Let's say that instead of just temperatures above
and below 80 degrees, we want to know the number of days when
temperatures were above 80, below 50, and in between.
When day is above 80, the if boolean condition is true and the variable
NumAbove80 increases by 1. If day is not above 80, the if boolean condition
is false and the selection structure moves to the elseif condition. Now, if day
is below 50, the elseif boolean condition is true and the variable
NumBelow50 increases by 1.
If the elseif boolean condition is false, then the conditional structure moves to
the else condition and the variable NumBtw50and80 increases by 1.
NOTE: This is a simplified example. This code will not operate by itself. For full
instructions on creating an elseif structure in MATLAB go to the elseif page.
At times you need to create selection structures that can select from many
alternatives. Such selection structure is known as multiple-alternative
selection structures.
The condition must result in either a true (yes) or false (no) answer. If the
condition is true, the program performs one set of tasks.
Relational Operators
Relational operators are used to compare two values in C language. It checks
the relationship between two values. If relation is true, it returns 1. However,
if the relation is false, it returns 0.
== Equal to
!= Not equal to
When we know how many times loop body will be executed known as
Counter Controlled Loop, for example - print natural numbers from 1 to
100, such kind of problem will be solved using counter controlled loop.
intcount;
for(count=1;count<=100;count++)
printf("%d",count);
Nested Loops
A nested loop means a loop statement inside another loop statement. That
is why nested loops are also called “loop inside loops“. We can define any
number of loops inside another loop.
Outer_loop
{
Inner_loop
{
// inner loop statements.
}
// outer loop statements.
}
The nested for loop means any type of loop which is defined inside the 'for'
loop.
Syntax
The nested while loop means any type of loop which is defined inside the
'while' loop.
Syntax
while(condition)
{
while(condition)
{
// inner loop statements.
}
// outer loop statements.
}
Nested do..while loop
The nested do..while loop means any type of loop which is defined inside the
'do..while' loop.
Syntax
do
{
do
{
// inner loop statements.
}while(condition);
// outer loop statements.
}while(condition);
return 0;
}
A) RABBIT
B) RABBIT is printed unlimited number of times.
C) No output
D) Compiler error.
int main()
{
int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
A) RABBIT is printed unlimited number of times
B) RABBIT
C) Compiler error
D) None of the above.
int main()
{
int a=5;
while(a=123)
{
printf("RABBIT\n");
break;
}
printf("GREEN");
return 0;
}
A) GREEN
B) RABBIT
GREEN
C) RABBIT is printed unlimited number of times.
D) Compiler error.
return 0;
}
A) GREEN
B) RABBIT
GREEN
C) RABBIT is printed infinite times
D) None of the above
int main()
{
int a=25;
return 0;
}
A) 25 25 25
B) 25 26 27
C) 27 27 27
D) Compiler error
do
{
printf("%d ", a);
a++;
}while(a <= 30);
return 0;
}
A) 32
B) 33
C) 30
D) No Output
int main()
{
int k;
for(;;)
{
printf("TESTING\n");
break;
}
return 0;
}
A) No Output
B) TESTING
C) Compiler error
D) None of the above
[Link] is the way to suddenly come out of or Quit any Loop in C Language.?
A) continue; statement
B) break; statement
C) leave; statement
D) quit; statement
28. The requirement for not repeating the instructions is referred to as the
__________
a) Loop exit condition
b) Looping condition
c) Conditional statement
d) Iterative statement
32. The __________ is used to code both pretest and posttest loops.
a) Do loop statement
b) For loop statement
c) While loop statement
d) If statement
34. How many times will the [Link] method in the following code
be processed?
intCount =0
Do While intCount> 3
[Link]("Hello")
intCount = intCount + 1
Loop
a) 0
b) 1
c) 3
d) 4
[Link] many times will the [Link] method in the following code be
processed?
intCount =0;
Do
[Link]("Hello")
intCount += 1
Loop While intCount> 3
a) 0
b) 1
c) 3
d) 4
[Link] structures that can select from many alternatives are known as
____
a) Selection structures
b) Multiple-alternative selection structures
c) Multiway selection structures
d) Multipath selection structures
if(a==10 OR b==21)
{
printf("Theatre");
}
return 0;
}
A) Theatre
B) Hurray
Theatre
C) No output
D) Compiler error
[Link] value is stored in the count variable when the loop ends?
For count As Integer = 5 to 9 Step 5
[Link](“Hi”)
Next count
a) 10
b) 9
c) 8
d) 7
FIVE MARKS
1. What is Selection structure? and its types?
2. Explain Relational Operators?
3. Explain Logical Operators?
4. Discuss Counter Controlled Loop?
5. Explain Applications of Repetition Structures ?
TEN MARKS
[Link] explain about if,if else, nested if,elif with examples?
2. Discuss About While,Do while Loop With Examples?
UNIT IV
Data
Data is information that has been translated into a form that is efficient
for movement or processing. Relative to today's computers and
transmission media, data is information converted into binary digital
form. It is acceptable for data to be used as a singular subject or a
plural subject.
Numeric data
This kind of data has two main categories: discrete and continuous data. You
can further divide continuous data into interval and ratio data. Here are their
definitions:
Discrete data:
Discrete data represents a set of countable items that are countably finite,
such as the numbers from one to hundred, or in other cases, infinite. Contrary
to continuous data, it always takes up natural number values.
Continuous data:
Interval data:
This is data that you can measure in relation to other data. For example, one
could say that the temperature on a Celsius or Fahrenheit scale is a particular
number that is lower or higher than normal body temperature.
Ratio data:
Much like interval data, you can measure ratio data in intervals with equal
values. The difference is that the latter includes a true zero (as in the Kelvin
temperature scale), and you can perform other arithmetic operations, such as
multiplication and division, on them.
Character data types are strings of characters. Upper and lower case
alphabetic characters are accepted literally. There is one fixed-length
character data type: char, and two variable-length character data types:
varchar and long varchar.
The maximum length of a character column cannot exceed 32,000 bytes for a
non-UTF-8 installation and 16,000 bytes for a UTF-8 installation.
Varchar strings are variable-length strings. The varchar data type can contain
any character, including non-printing characters and the ASCII null character
('\0').
Except when comparing with char data, blanks are significant in the varchar
data type. For example, the following two varchar strings are not considered
equal:
'the store is closed'
and
'thestoreisclosed'
If the strings being compared are unequal in length, the shorter string is
padded with trailing blanks until it equals the length of the longer string.
For example, consider the following two strings:
'abcd\001'
where:
'\001' represents one ASCII character (ControlA)
and
'abcd'
If they are compared as varchar data types, then
'abcd' > 'abcd\001'
because the blank character added to 'abcd' to make the strings the same
length has a higher value than ControlA ('\040' is greater than '\001').
Array
An array is a group of similar elements or data items of the same type
collected at contiguous memory locations. In simple words, we can say that in
computer programming, arrays are generally used to organize the same type
of data
Representation of an Array:
Arrays can be represented in several ways, depending on the different
languages. To make you understand, we can take one example of the C
language. The picture below shows the representation of the array.
Arrays always store the same type of values. In the above example:
2 5 8 44 21 11 7 9 3 1
f d a b n j l s e y
Initialization of an Array:
If an array is described inside a function, the elements will have garbage
value. And in case an array is static or global, its elements will be initialized
automatically to 0.
We can say that we can simply initialize elements of an array at the time of
declaration and for that, we have to use the proper syntax:
Syntax: datatype Array_Name[size] = { value1, value2, value3, …..valueN };
Types of Arrays:
There are two types of arrays:
One-Dimensional Arrays
Multi-Dimensional Arrays
Multi-Dimensional Arrays
In multi-dimensional arrays, we have two categories:
Two-Dimensional Arrays
Three-Dimensional Arrays
1. Two-Dimensional Arrays
An array involving two subscripts [] [] is known as a two-dimensional array.
They are also known as the array of the array. Two-dimensional arrays are
divided into rows and columns and are able to handle the data of the table.
Syntax: DataTypeArrayName[row_size][column_size];
For Example: int arr[5][5];
2. Three-Dimensional Arrays
When we require to create two or more tables of the elements to declare the
array elements, then in such a situation we use three-dimensional arrays.
Syntax: DataTypeArrayName[size1][size2][size3];
For Example: int a[5][5][5];
Advantages of Array
It is a better version of storing the data of the same size and same type.
It enables us to collect the number of elements in it.
Arrays have a safer cache positioning that improves performance.
Arrays can represent multiple data items of the same type using a single
name.
Disadvantages Of Array:
String is a sequence of characters that are treated as a single data item and
terminated by a null character '\0'. Remember that the C language does not
support strings as a data type.
If you don't know what an array in C means, you can check the C
Array tutorial to know about Array in the C language. Before proceeding
further, check the following articles:
For example: The string "home" contains 5 characters including the '\0' character
which is automatically added by the compiler at the
// valid
// Illegal
char str[4];
str = "hello";
edit set conversion code %[..] that can be used to read a line containing a
variety of characters, including white spaces.
The gets() function can also be used to read character string with white spaces
[Link][20];
printf("Enter a string");
scanf("%[^\n]",&str);
printf("%s", str);
[Link][20];
gets(text);
printf("%s", text);
The following are the most commonly used string handling functions.
Method Description
strcat() function in C:
The strcat() will add the string "world" to "hello" [Link] = helloworld.
The strlen() will return the length of the string passed to it and strcmp() will
return the ASCII difference between first unmatching character of two
strings.
strcpy() function:It copies the second string argument to the first string argument.
ONE MARKS
a) Array
b) List
c) Relation
d) Variable group
a) Reference
b) Subscript
c) Array
d) ID
a) null
b) Null
c) 0
d) Nothing
a) Populating an array
b) Assigning array
c) Initializing
a) Compilation Error
b) Runtime Error
A) -1
B) 0
C) 1
D) 2
int main()
int a[];
a[4] = {1,2,3,4};
printf("%d", a[0]);
A) 1
B) 2
C) 4
D) Compiler error
#include <stdio.h>
void main()
int i = 0, j = 0;
printf("%d", a[i][j]);
}
a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
#include <stdio.h>
void main()
int i = 0, j = 0;
printf("%d", a[i][j]);
a) 1 2 3 junk 4 5
c) 1 2 3 0 4 5
d) 1 2 3 3 4 5
#include <stdio.h>
a[0][1] = 3;
int i = 0, j = 0;
printf("%d", a[i][j]);
void main()
f(a); }
a) 0 3 0 0 0 0
#include <stdio.h>
a[0][1] = 3;
int i = 0, j = 0;
printf("%d", a[i][j]);
}
void main()
f(a);
a) 0 3 0 0 0 0
int (*a)[7];
c) A ragged array
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array
a) 32 characters
b) 64 characters
c) 256 characters
a) SCANF
b) GETS
c) GETC
d) FINDS
A. Two
B. eight
C. sixteen
D. Theoratically no limit. The only practical limits are memory size and
compilers
22. What will be the address of the arr[2][3] if arr is a 2-D long array of 4 rows
and 5 columns and starting address of the array is 2000?
A. 2048
B. 2056
C. 2052
D. 2042
C. Same scope
D. None of these
A. Compile time
B. Run time
C. Both A and B
B. It is a formal parameter
C. It is a declaratrion
A. Symbol Table
B. Activation Record
C. Dope Vector
D. Both A and B
B. call by reference
C. call by value-result
B. A pointer to character
C. Both A and B
29. Which of the following function is more appropriate for reading in a multi-
word string?
A. scanf()
B. printf()
C. gets()
D. puts()
A. printf("");
B. printf('');
C. printf("\n");
D. printf(""")
B. Always
32. The library function used to find the last occurrence of a character in a
string is
A. strnstr()
B. laststr()
C. strrchr()
D. strstr()
A. Sequential
B. Random
void main()
printf("%d", a[5]);
A. 5
B. 6
C. 0
D. Garbage Value
void main()
{
int arr[10];
A. 0 0
B. Garbage value 0
D. Compilation Error
#include <stdio.h>
int main()
int p, q, r;
p = ++arr[1];
q = arr[1]++;
r = arr[p++];
return 0;
A. 3 4 5
B. 3 4 4
C. 4 3 4
D. 4 4 5
a) int
b) struct
c) float
d) double
d) None of these
int main()
int i;
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
41. The format identifier '%i' is also used for _____ data type?
A. char
B. int
C. float
D. double
42. Which data type is most suitable for storing a number 65000 in a 32-bit
system?
A. short
B. int
C. long
D. double
A. 4 Bytes
B. 8 Bytes
D. Cannot be determined.
int main()
char chr;
chr = 128;
printf("%d\n", chr);
return 0;
A. 128
B. - 128
B. Qualifier
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf("equal\n");
else
printf("not equal\n");
A. equal
B. not equal
int main()
float f1 = 0.1;
if (f1 == 0.1f)
printf("equal\n");
else
printf("not equal\n");}
A. equal
B. not equal
int main()
float x = 'a';
printf("%f", x);
return 0;
A. a
C. a.0000000
D. 97.000000
FIVE MARKS
1. Explain types of numeric data?
2 .Discuss about types of Array?
3. Explain Advantages and Disadvantages of Array?
[Link] String Handling Functions?
5. Explain Strings? Declaring and Initializing a string variables?
TEN MARKS
[Link] Explain about Array? And its types with examples?
2. Briefly discuss about strings? and string handling functions?
UNIT V
DFD is the abbreviation for Data Flow Diagram. The flow of data of a
system or a process is represented by DFD. It also gives insight into the
inputs and outputs of each entity and the process itself.
DFD does not have control flow and no loops or decision rules are present.
Specific operations depending on the type of data can be explained by a
flowchart.
It is a graphical tool, useful for communicating with users ,managers and
other personnel. it is useful for analyzing existing as well as proposed
system.
It provides an overview of
What data is system processes.
What transformation are performed.
What data are stored.
What results are produced , etc.
Data Flow Diagram can be represented in several ways. The DFD belongs to
structured-analysis modeling tools.
Data Flow diagrams are very popular because they help us to visualize the
major steps and data involved in software-system processes.
Data Flow Diagram (DFD) is a graphical representation of data flow in any
system. It is capable of illustrating incoming data flow, outgoing data flow and
store data. Data flow diagram describes anything about how data flows through the
system.
Sometimes people get confused between data flow diagram and flowchart.
There is a major difference between data flow diagram and flowchart. The
flowchart illustrates flow of control in program modules. Data flow
diagrams illustrate flow of data in the system at various levels. Data flow
diagram does not have any control or branch elements.
Types of DFD :
DFD is of two types:
[Link] DFD:
[Link] DFD:
1. Logical DFD:
Logical data flow diagram mainly focuses on the system process. It illustrates
how data flows in the system. Logical DFD is used in various organizations for
the smooth running of system. Like in a Banking software system, it is used to
describe how data is moved from one entity to another.
2. Physical DFD:
Physical data flow diagram shows how the data flow is actually implemented in
the system. Physical DFD is more specific and close to implementation.
A data flow diagram has four basic elements. The elements include external
entities, data stores, processes, and data flows. The elements are best
represented by the two main methods of notation used in DFDs – Yourdon &
Coad, and Gane & Sarson. DFD symbols vary slightly depending on
methodology. Even so, the basic ideas remain the same.
faster re-compilation, as only the modules that have been modified are
actually re-compiled;
Reference Parameters
A reference parameter is a reference to a memory location
of a variable. When you pass parameters by reference,
unlike value parameters, a new storage location is not
created for these parameters. The reference parameters
represent the same memory location as the actual
parameters that are supplied to the method.
You can declare the reference parameters using the ref
keyword.
#include<stdio.h>
intmain()
{
intmy_num=7;
{
//add 10 my_num
my_num=my_num+10;
//or my_num +=10 - more succinctly
printf("my_num is %d",my_num);
}
return0;
}
Let's understand what the above program does.
Output
my_num is 17
The inner block is able to access the value of my_num that's declared
in the outer block, and modify it by adding 7 to it.
The value of my_num is now 17, as indicated in the output.
Functions
A function is a group of statements that together perform a task. Every C
program has at least one function, which is main(), and all the most trivial
programs can define additional functions.
You can divide up your code into separate functions. How you divide up your
code among different functions is up to you, but logically the division is such
that each function performs a specific task.
A function declaration tells the compiler about a function's name, return
type, and parameters. A function definition provides the actual body of the
function.
The C standard library provides numerous built-in functions that your
program can call. For example, strcat() to concatenate two
strings, memcpy() to copy one memory location to another location, and
many more functions.
Defining a Function
The general form of a function definition in C programming language is as
follows −
return_typefunction_name( parameterlist ){
body of the function
}
A function definition in C programming consists of a function header and
a function body. Here are all the parts of a function −
Return Type − A function may return a value. The return_type is the data
type of the value the function returns. Some functions perform the desired
operations without returning a value. In this case, the return_type is the
keyword void.
Function Name − This is the actual name of the function. The function name
and the parameter list together constitute the function signature.
Parameters − A parameter is like a placeholder. When a function is invoked,
you pass a value to the parameter. This value is referred to as actual parameter
or argument. The parameter list refers to the type, order, and number of the
parameters of a function. Parameters are optional; that is, a function may
contain no parameters.
Function Body − The function body contains a collection of statements that
define what the function does.D
Example
Given below is the source code for a function called max(). This function
takes two parameters num1 and num2 and returns the maximum value
between the two −
/* function returning the max between two numbers */
intmax(int num1,int num2){
return result;
}
Function Declarations
A function declaration tells the compiler about a function name and how to
call the function. The actual body of the function can be defined separately.
A function declaration has the following parts −
return type function_name( parameterlist );
For the above defined function max(), the function declaration is as follows −
int max(int num1, int num2);
Parameter names are not important in function declaration only their type is
required, so the following is also a valid declaration .
int max(int, int);
Function declaration is required when you define a function in one source file
and you call that function in another file. In such case, you should declare the
function at the top of the file calling the function.
Calling a Function
While creating a C function, you give a definition of what the function has to
do. To use a function, you will have to call that function to perform the
defined task.
When a program calls a function, the program control is transferred to the
called function. A called function performs a defined task and when its return
statement is executed or when its function-ending closing brace is reached, it
returns the program control back to the main program.
To call a function, you simply need to pass the required parameters along
with the function name, and if the function returns a value, then you can store
the returned value. For example
#include<stdio.h>
/* function declaration */
intmax(int num1,int num2);
return0;
}
return result;
}
We have kept max() along with main() and compiled the source code. While
running the final executable, it would produce the following result −
Max value is : 200
Function Arguments
If a function is to use arguments, it must declare variables that accept the
values of the arguments. These variables are called the formal parameters of
the function.
Formal parameters behave like other local variables inside the function and
are created upon entry into the function and destroyed upon exit.
While calling a function, there are two ways in which arguments can be passed to a
function −
1 Call by value
2 Call by reference
Recursion
Recursion is the process of repeating items in a self-similar way. In
programming languages, if a program allows you to call a function inside the
same function, then it is called a recursive call of the function.
voidrecursion(){
recursion();/* function calls itself */
}
intmain(){
recursion();
}
The C programming language supports recursion, i.e., a function to call itself.
But while using recursion, programmers need to be careful to define an exit
condition from the function, otherwise it will go into an infinite loop.
Recursive functions are very useful to solve many mathematical problems,
such as calculating the factorial of a number, generating Fibonacci series, etc.
Number Factorial
The following example calculates the factorial of a given number using a
recursive function
#include<stdio.h>
unsignedlonglongintfactorial(unsignedinti){
if(i<=1){
return1;
}
returni*factorial(i-1);
}
int main(){
inti=12;
printf("Factorial of %d is %d\n",i, factorial(i));
return0;
}
When the above code is compiled and executed, it produces the following result
Factorial of 12 is 479001600
Fibonacci Series
The following example generates the Fibonacci series for a given number
using a recursive function
#include<stdio.h>
intfibonacci(inti){
if(i==0){
return0;
}
if(i==1){
return1;
}
returnfibonacci(i-1)+fibonacci(i-2);
}
int main(){
inti;
for(i=0;i<10;i++){
printf("%d\t\n",fibonacci(i));
}
return0;
}
When the above code is compiled and executed, it produces the following result
0
1
1
2
3
5
8
File
The data to be displayed may be very large, and only a limited amount of data
can be displayed on the console, and since the memory is volatile, it is
impossible to recover the programmatically generated data again and again.
However, if we need to do so, we may store it onto the local file system
which is volatile and can be accessed every time. Here, comes the need of file
handling in C.
File handling in C enables us to create, update, read, and delete the files stored on
the local file system through our C program. The following operations can be
performed on a file.
There are many functions in the C library to open, read, write, search and
close the file. A list of file functions are given below:
Sequential files
A sequential file is an ordinary text file. Each character in the file is assumed
to be either a text character or some other ASCII control character such as
newline.
The character is in the character set specified when the file is opened. By
default this is the platform-native character set.
Sequential files provide access at the level of lines or strings of text: that is,
data that is not divided into a series of records.
However, a sequential file is not well suited for binary data, because a
number in a sequential file is written as a character string.
depending on the disposition of any leftover characters in the input record, where
the filename appears in the program statement and the record name variable will
receive the data.
Writing a file − A write operation generates a new component at the content
position in the file and shift the contents of a designated program variable to the
new component. In COBOL
WRITE record-name [FROM identifier]
Where the record name is defined in the file’s FD (file description) and the
optional identifier of the FROM clause is defined in WORKING-STORAGE
In PASCAL-
writeln (Filename, recordname);
write (Filename, recordname);
depending upon whether or not a new line is to be started after this one, where the
filename appears in the program statement and the record name variable will
include the information to be written. The record will appear on the file in the same
order as they are written.
Updating a file − It can modify the contents of a master file to create it follow
a more current snapshot of the real world is called updating the file. These
changes can include the insertion, deletion, and modification of records.
Retrieving from a file − The access of a file for goals of deriving meaningful
data is called retrieval.
Maintaining a file − Changes that are made to files to enhance the
implementation of the programs that create them are known as maintenance
activities.
End-of-file test − An explicit test for the end-of-file position is required
therefore that the program can take a specific action. Pascal provides a
function.
ONE MARKS
A. structure chart
B. data-flow diagram
C. program flowchart
D. module
A) True
B) False
[Link] first component of the DFD is known as a ....... Common synonyms are a
bubble, a function, or a transformation.
A) Flow
B) Process
C) Square
D) Entity
A) Process
B) Entity
C) Level
D) Flow
[Link] data flow on one level can be split into its component data flows
on the next level - but new data cannot be added and all data in the composite
must be included in the sub-flows
A) True
B) False
6.A data flow may or may not be attached to at least one process
A) True
B) False
7..... is to organize the overall DFD in a series of levels so that each level
provides successively more detail about a portion of the level above it.
A) Split DFDs
B) LEVELED DFDs
C) Flow DFDs
D) All of Above
A. physical file
B. data structure
C. logical file
A) level 0 diagram
B) level 1 diagram
C) level A diagram
D) Both A & B
a) Variable
b) Array
c) Structures
a) object file
b) source file
c) executable file
d) text file
13. Which type of variables can have the same name in a different function?
a) Global variables
b) Static variables
c) Function arguments
[Link] that take input by user before running a program are called?
b) Main arguments
c) Command-Line arguments
d) Parameterized arguments
a) 127
b) 253
c) 361
#include <stdio.h>
void main()
{
int a = 6, b = 5;
m(&a, &b);
a) 5 6
b) 6 5
c) 5 5
d) 6 6
include <stdio.h>
int i = 0;
printf("%d\t", p[i]);
void main()
m(&a);
a) 0 0 0 0 0
b) 6 5 3 0 0
d) 6 5 3 junk junk
a) Variable
b) Array
c) Structures
19. Which type of variables can have the same name in a different function?
a) Global variables
b) Static variables
c) Function arguments
20. Arguments that take input by user before running a program are called?
b) Main arguments
c) Command-Line arguments
d) Parameterized arguments
21. What is the maximum number of arguments that can be passed in a single
function?
a) 127
b) 253
c) 361
#include <stdio.h>
void main()
int a = 6, b = 5;
m(&a, &b);
a) 5 6
b) 6 5
c) 5 5
d) 6 6
#include <stdio.h>
int i = 0;
printf("%d\t", p[i]);
}
void main()
m(&a);
a) 0 0 0 0 0
b) 6 5 3 0 0
d) 6 5 3 junk junk
#include <stdio.h>
int temp = p;
p = q;
q = temp;
void main()
int a = 6, b = 5;
m(a, b);
}
a) 5 6
b) 5 5
c) 6 5
d) 6 6
[Link]
a) Variable
b) Array
c) Structures
26. Which type of variables can have the same name in a different function?
a) Global variables
b) Static variables
c) Function arguments
27. Arguments that take input by user before running a program are called?
b) Main arguments
c) Command-Line arguments
d) Parameterized arguments
28. What is the maximum number of arguments that can be passed in a single
function?
a) 127
b) 253
c) 361
#include <stdio.h>
void main()
int a = 6, b = 5;
m(&a, &b);
a) 5 6
b) 6 5
c) 5 5
d) 6 6
#include <stdio.h>
int i = 0;
void main()
m(&a);
a) 0 0 0 0 0
b) 6 5 3 0 0
d) 6 5 3 junk junk
#include <stdio.h>
int temp = p;
p = q;
q = temp;
void main()
{
int a = 6, b = 5;
m(a, b);
a) 5 6
b) 5 5
c) 6 5
d) 6 6
#include <stdio.h>
void main()
int a = 6, b = 5;
m(a);
a) 6
b) 6 5
c) 6 junk value
#include <stdio.h>
void m(int p)
printf("%d\n", p);
void main()
int a = 6, b = 5;
m(a, b);
a) 6
b) 6 5
c) 6 junk value
A) printf()
B) show()
C) scanf()
D) main()
A) 1
B) 2
C) 3
D) 4
int main()
printf("ROCKET ");
show();
return 0;
printf("STATIC");
A) ROCKET
B) ROCKET STATIC
C) STATIC ROCKET
D) Compiler error
A) 64
B) 128
C) 256
A) Alphabets, Numbers, %, $, _
D) Alphabets, Numbers, %
p = &a;
A) Formal arguments
B) Actual Arguments
C) Definite Arguments
D) Ideal Arguments
A) Definite arguments
B) Formal arguments
C) Actual arguments
D) Ideal arguments
[Link] a corrects statement about C language function arguments.
A) printf()
B) scanf()
C) fprintf()
D) printf2()
int funny2()
funny2(num);
A) Indefinite Function
B) Definite Function
C) Cursive Function
D) Recursive Function
b) From the point of declaration to the end of the file in which it is defined
c) Any source file in a program
d) From the point of declaration to the end of the file being compiled
b) From the point of declaration to the end of the file in which it is defined
d) From the point of declaration to the end of the file being compiled
[Link] sizes are optional during array declaration by using ______ keyword.
a) auto
b) static
c) extern
d) register
#include <stdio.h>
void main()
int x = 3;
x = 4;
printf("%d", x);
} }
a) 4
b) 3
c) 0
d) Undefined
#include <stdio.h>
int x = 5;
void main()
int x = 3;
m();
printf("%d", x);
void m()
x = 8;
n();
void n()
printf("%d", x);
a) 8 3
b) 3 8
c) 8 5
d) 5 3
a) Self Function
b) Auto Function
c) Recursive Function
d) Static Function
a) Library Functions
a) Pass By Value copies the variable value in one more memory location
a) Definite arguments
b) Formal arguments
c) Actual arguments
d) Ideal arguments
a) Array
b) Linked list
c) Binary tree
d) Stack
c) Logical error
d) No error
d) FILE open(const*filename)
[Link](NULL) flushes all ____________
a) input streams
b) output streams
c) previous contents
d) appended text
a) remove(const *filename)
b) remove(filename)
c) remove()
d) fclose(filename)
[Link] does tmpfile() returns when it could not create the file?
b) only stream
c) only NULL
a) 1
b) 0
c) NULL
d) – 1
63.A mode which is used to open an existing file for both reading and
writing ______
a) ”W”
b) ”W+”
c) ”R+”
d) ”A+”
a) pits()
b) putc()
c) fputs()
d) fgets()
a) fscanf()
b) getch()
c) fgetc()
d) fgets()
[Link] a program which get input data from datafile and also send
output into datafile ,it is called _____
a) files
b) file processing
c) data files
d) file handling
[Link] text file in which data is stored in ________
a) ASCII code
b) Binary code
c) Octal code
d) text code
a) text stream
b) binary stream
c) output stream
d) input stream
a) file name
b) file extension
c) file identifier
70.______ is a unique tag, usually a number identifies the file within the
file system.
a) File identifier
b) File name
c) File type
c) allocate the space in file system & make an entry for new file in
directory
computer can be defined as an electronic device capable of processing the data and
producing the information.
The computer system essentially comprises three important parts –
[Link] device,
[Link] processing unit (CPU) and
[Link] device.
The CPU itself is made of three components namely,
[Link] logic unit (ALU),
[Link] unit, and
[Link] unit.
FIVE MARKS
TEN MARKS
Subject Code Subject Name Category L T P S Credits Inst. Hours Marks CIA External Total FC Problem
Solving Techniques FC 2 - - - 2 2 25 75 100 Learning Objectives LO1 Familiarize with writing of
algorithms, fundamentals of C and philosophy of problem solving. LO2 Implement different
programming constructs and decomposition of problems into functions. LO3 Use data flow diagram,
Pseudo code to implement solutions. LO4 Define and use of arrays with simple applications LO5
Understand about operating system and their uses UNIT Contents No. Of. Hours I Introduction: History,
characteristics and limitations of Computer. Hardware/Anatomy of Computer: CPU, Memory, Secondary
storage devices, Input Devices and Output devices. Types of Computers: PC, Workstation,
Minicomputer, Main frame and Supercomputer. Software: System software and Application software.
Programming Languages: Machine language, Assembly language, Highlevel language,4 GL and 5GL-
Features of good programming language. Translators: Interpreters and Compilers. 6 II Data: Data types,
Input, Processing of data, Arithmetic Operators, Hierarchy of operations and Output. Different phases in
Program Development Cycle (PDC).Structured Programming: Algorithm: Features of good algorithm,
Benefits and drawbacks of algorithm. Flowcharts: Advantages and limitations of flowcharts, when to use
flowcharts, flowchart symbols and types of flowcharts. Pseudocode: Writing a pseudocode. Coding,
documenting and testing a program: Comment lines and types of errors. Program design: Modular
Programming. 6 III Selection Structures: Relational and Logical Operators - Selecting from Several
Alternatives – Applications of Selection Structures. Repetition Structures: Counter Controlled Loops –
Nested Loops– Applications of Repetition Structures. 6 IV Data: Numeric Data and Character Based Data.
Arrays: One Dimensional Array - Two Dimensional Arrays – Strings as Arrays of Characters. 6 24 V Data
Flow Diagrams: Definition, DFD symbols and types of DFDs. Program Modules: Subprograms-Value and
Reference parameters- Scope of a variable - Functions – Recursion. Files: File Basics-Creating and
reading a sequential file- Modifying Sequential Files. 6 TOTAL HOURS 30 Course Outcomes Programme
Outcomes CO On completion of this course, students will CO1 Study the basic knowledge of
Computers. Analyze the programming languages. PO1, PO2, PO3, PO4, PO5, PO6 CO2 Study the data
types and arithmetic operations. Know about the algorithms. Develop program using flow chart and
pseudocode. PO1, PO2, PO3, PO4, PO5, PO6 CO3 Determine the various operators. Explain about the
structures. Illustrate the concept of Loops PO1, PO2, PO3, PO4, PO5, PO6 CO4 Study about Numeric data
and character-based data. Analyze about Arrays. PO1, PO2, PO3, PO4, PO5, PO6 CO5 Explain about DFD
Illustrate program modules. Creating and reading Files PO1, PO2, PO3, PO4, PO5, PO6 Textbooks 1
Stewart Venit, ―Introduction to Programming: Concepts and Design‖, Fourth Edition, 2010, Dream Tech
Publishers. Web Resources 1. [Link]
[Link] 2. [Link] 3.
[Link] Mapping with Programme Outcomes: CO/PSO PSO 1 PSO 2 PSO 3
PSO 4 PSO 5 PSO 6 CO 1 3 3 3 3 3 3 CO 2 3 3 3 3 3 3 CO 3 3 2 3 3 3 3 CO 4 3 3 2 3 3 3 CO 5 3 3 3 3 3 2 25
Weightage of course contributed to each PSO 15 14 14 15 15 14 S-Strong-3 M-Medium-2 L-Low-1