0% found this document useful (0 votes)
8 views164 pages

Problem Solving Techniques Course Overview

The document outlines the syllabus for a course titled 'Problem Solving Techniques' which focuses on foundational skills in computer science, including programming languages, algorithms, and data structures. It details course outcomes, mapping with program outcomes, and a comprehensive syllabus divided into five units covering computer hardware, software, programming concepts, and data flow diagrams. Additionally, it includes evaluation methods, learning resources, and a model question paper for assessment.

Uploaded by

shenbagam naren
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views164 pages

Problem Solving Techniques Course Overview

The document outlines the syllabus for a course titled 'Problem Solving Techniques' which focuses on foundational skills in computer science, including programming languages, algorithms, and data structures. It details course outcomes, mapping with program outcomes, and a comprehensive syllabus divided into five units covering computer hardware, software, programming concepts, and data flow diagrams. Additionally, it includes evaluation methods, learning resources, and a model question paper for assessment.

Uploaded by

shenbagam naren
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

EVEN SEMSTER

Paper Title - PROBLEM SOLVING TECHNIQUES


Semester Course Code Course Name Category L T P Credits
PROBLEM 5 - - -
SOLVING
TECHNIQUES
25UCSS01/ Foundation
I 25UCSN01 Course FC

Problem solving is a creative journey of understanding the issue, devising a


plan, executing it, and reflecting on the outcome to learn and improve for next
Preamble time
Essential foundational skills like critical thinking, analytical reasoning,
creativity, adaptability, decision-making, research, communication, teamwork,
Prerequisite and time management.

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

Mapping with Program Outcomes:

Cos/Pos PO1 PO2 PO3 PO4 PO5


CO1 3 3 3 3 3

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]

Here are several effective learning methods to teach and practice


Learning Methods problem-solving techniques, combining theory with actionable steps

Here’s a refined breakdown of what a “Problem Solving Techniques”


course typically focuses on its structure, core principles, and key
Focus of the Course learning outcomes.
Methods of Evaluation
Continuous Internal Assessment Test

Assignments
25 Marks
Seminar

Internal Evaluation Attendance and Class participation


75 Marks
External Evaluation End Semester Examinations
100 Marks
Total

MODEL QUESTION PAPER

Time: 3 Hours Maximum :75 Marks

PART-A (15*1 =15 Marks)

(Answer All Questions)

1. Which of the following is a Permanent Memory in the computer?

[Link] [Link] [Link] [Link] ROM

2. It is also called as online input device.


A. Web camera B. Joystick C. Keyboard D. Mouse
3._____________ are used for solving complex application such as Global Weather Forecasting.
A. Super Computers B. Public computers
C. Mobile computers D. Hybrid computers

4. Which of the following is not a data type?


a) Symbolic Data b) Alphanumeric Data
c) Numeric Data d) Alphabetic Data

5. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
a) Syntax error b) 1 c) 10 d) 5

6. A detailed flowchart is called ______


a) Stack b) Macro c) Micro d) Union

7. The __________ in a Do…Loop statement can contain variables, methods, constants,


properties and operators.
a) Exit statement b) Condition c) Statement d) Iteration statement
8. Which of the following is an exit controlled loop?
a) While loop b)For loop c)do-while loop d)None of the above
9. An expression contains relational, assignment and arithmetic operators. If parenthesis are not
specified, the order of evaluation of the operators would be:
A. assignment, arithmetic, relational B. relational, assignment, arithmetic
C. assignment, relational, arithmetic D. arithmetic, relational, assignment
10. Using array in a program is efficient because ______

a. It shortens the program b. The program compiles faster

c. Number of variables are reduced d. Data is accessed faster

11. What is an Array in C language.?

A. A group of elements of same data type B. An array contains more than one element

C. Array elements are stored in memory in continuous or contiguous locations.

D. All the above.

12. Array is ____ datatype in C Programming language.

a. Derived Data type b. Primitive Data type

c. Custom Data type d. None of these

13. The principle of stack is __________

a. First in first out b. First in last out

c. Last in first out d. Last in last out

14. ______ is a unique tag, usually a number identifies the file within the file system.

a) File identifier b) File name c) File type d) None of the mentioned


15. Which type of variables can have the same name in a different function?

a. Global variables b. Static variables

c. Function arguments d. Both static variables and Function arguments

PART-B (5*2 =10 Marks)

16. what is software? and explain its types?


17. Discuss about Arithmetic operators?
18. What is Selection structure? and its types?
19. Explain types of numeric data?

20. What is DFD? Types of DFD?

PART-C (10*5 =50 Marks)

(Answer ALL Questions)

21. A. Briefly discuss about harware? and its components?


(OR)
[Link] about features of 4GL and 5GL?
22. A. Briefly Explain about Algorithms?
(OR)
[Link] about Flowcharts
23. A. Briefly explain about if,if else, nested if,elif with examples?
(OR)
B. Discuss About While,Do while Loop With Examples?
24. A. Briefly Explain about Array? And its types with examples?
( OR)
B. Briefly discuss about strings? and string handling functions?
[Link] explain about Functions ? and its Declarations and parameters?

(OR)

B .Briefly discuss about File ? and its Functionsand operations?


UNIT I

What is computer? Characteristics and Limitations of Computer

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.

Characteristics or Features of Computer

 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:

 Input and output devices


 Central processing unit (CPU)
 Memory unit and storage devices
 Interface unit

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:

 Kilobyte (KB) = 1024 bytes


 Megabyte (MB) = 1024 Kilobytes
 Gigabyte (GB) = 1024 Megabytes
 Terabyte (TB) = 1024 Gigabytes
 Petabyte (PB) = 1024 Terabytes
 Exabyte (EB) = 1024 Petabytes
 Zettabyte (ZB) = 1024 Exabytes
 Yottabyte (YB) = 1024 Zettabytes

 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.

Functions of System Software

 Memory Management
 Processor Management
 File Management
 Security
 Error-detecting Aids
 Scheduling

Features of System Software

 System software is written in a low-level language.


 The size of the system Software is smaller.
 System software is complex to understand.
 System software is present near hardware components.

Types of System Software

 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.

 Language Processor: System Software converts Human-Readable Language into a Machine


Language and it is done by Language Processor. It converts programs into instructions that
are easily readable by Machines.

 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.

Functions of Application Software

 Information and data management


 Management of documents (document exchange systems)
 Development of visuals and video
 Emails, text messaging, audio, and video conferencing, and cooperation are all
options.
 Management of accounting, finance, and payroll
 Management of resources (ERP and CRM systems)

Features of Application Software

 Application software is written in a high-level language.


 Application software requires more storage space than system software.
 Only a single task is performed by each application software.
 Application Software is easy to build in comparison to system software.

Types of Application Software

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

Machine Language (low 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.

Assemblylevellanguage (Middle-level 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.

Fourth Generation Language (4GL)

 A Fourth Generation (Programming) Language (4GL) is a grouping of programming


languages that attempt to get closer than 3GLs to human language, a form of thinking,
and conceptualization and are easier to use than 3GLs.
 It is a non-procedural language which means that the programmer defines what has to be
done instead of how the task is to be completed.I4GL is more familiar and similar to
human language.
 A compiler translates the whole program once i.e. it generates the object code for the
program along with the list of errors. The execution is very fast. It allows users to
develop software.
 These languages are usually designed for specific purposes and are commonly used in
database programming and scripts such as PHP, Python, SQL, and many more.
 4GLs make programming easier, more efficient, and more effective for users with less
programming skills.
 4th generation language is also known as a domain-specific language or a high-
productivity language.

Features of 4GL:

 It reduces programming costs and time.


 It is a high-level programming language.
 Its program has greater usability.
 It accesses the database.
 Minimum efforts from the user to obtain any information.

Fifth Generation Language (5GL)

 A fifth-generation programming language is based on solving using constraints given to


the program rather than using an algorithm written by a programmer. It is introduced in the
1990s.
 It very closely resembles human speech. Examples are PROLOG, Mercury, OPS5, AI, etc.
These programming languages are designed to make the computer smarter and more
intelligent. It is mainly used in artificial intelligence research.
 The programming language of this generation focus on constraints programming. The
constraints programming is similar to that of declarative programming.
 Declarative programming is a programming paradigm in which the programmer only
needs to specify the solutions to be found within the constraints rather than specifying the
method or algorithm of finding the desired solution.
 The major fields in which Fifth generation programming languages are employed are
Artificial Intelligence (AI) and Artificial Neural Network (ANN). The following are some
of the fifth-generation programming languages Mercury, Prolog, OPS5, etc.
 Fifth-generation languages are used in the field of Artificial Intelligence. It is
constraints-based programming. When larger programs are introduced then it becomes
difficult for creating the algorithm to solve the problems.
 Then it becomes necessary to create such algorithms and hence there is an introduction
of 5GL. PROLOG (Programming Logic) is an example of fifth-generation language. It
is based on mathematical logic to solve the problems given by the programmer.
 Fifth-generation language is a constraints-based programming language. It is a
programming language that contains visual tools to help develop a program. It uses system
automation. It is used in AI (Artificial Intelligence) research.
 Fifth-generation languages use some AI technologies natural language processing (NLP),
visual programming, and a graphical approach to programming.
 Codes are automatically generated and designed to make the computer solve a problem
without a programmer or with minimum programming effort.
Features of 5GL
MERCURY
 Mercury is a 5th generation programming language. It is a logical programming language.
It is used to create very large programs and is very fast and reliable.
 The syntax of Mercury and Prolog both are the same. But both the languages are different
as Mercury's module system, type, and mode are different.
 The programmers can create their own abstract data types according to its use in Mercury.
It handles dynamic data structures and provides several abstract data types.
 It is very efficient and is a modded language. It is a declarative programming language. It
has a module system that is very strong and it also supports higher-order programming.

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, compilers, interpreters and assemblers are all software


programming tools that convert code into another type of code, but each
term has specific meaning.
 All of the above work in some way towards getting a high-level
programming language translated into machine code that the central
processing unit (CPU) can understand.
 Examples of CPUs include those made by Intel (e.g., x86), AMD (e.g.,
Athlon APU), NXP (e.g., PowerPC), and many others. It’s important to
note that all translators, compilers, interpreters and assemblers are
programs themselves.

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

 Compilers convert high-level language code to machine (object) code in one


session. Compilers can take a while, because they have to translate high-level
code to lower-level machine language all at once and then save the executable
object code to memory.
 A compiler creates machine code that runs on a processor with a specific
Instruction Set Architecture (ISA), which is processor-dependent. For
example, you cannot compile code for an x86 and run it on a MIPS
architecture without a special compiler. Compilers are also platform-
dependent.
 That is, a compiler can convert C++, for example, to machine code that’s
targeted at a platform that is running the Linux OS. A cross-compiler,
however, can generate code for a platform other than the one it runs on itself.

Interpreters

 Another way to get code to run on your processor is to use an interpreter,


which is not the same as a compiler. An interpreter translates code like a
compiler but reads the code and immediately executes on that code, and
therefore is initially faster than a compiler.
 Thus, interpreters are often used in software development tools as debugging
tools, as they can execute a single in of code at a time.
 Compilers translate code all at once and the processor then executes upon the
machine language that the compiler produced. If changes are made to the
code after compilation, the changed code will need to be compiled and added
to the compiled code (or perhaps the entire program will need to be re-
compiled.) But an interpreter, although skipping the step of compilation of
the entire program to start, is much slower to execute than the same program
that’s been completely compiled.

Assemblers

 An assembler translates a program written in assembly language into machine


language and is effectively a compiler for the assembly language, but can also
be used interactively like an interpreter.
 Assembly language is a low-level programming language. Low-level
programming languages are less like human language in that they are more
difficult to understand at a glance; you have to study assembly code carefully
in order to follow the intent of execution and in most cases, assembly code
has many more lines of code to represent the same functions being executed
as a higher-level language.
 An assembler converts assembly language code into machine code (also
known as object code), an even lower-level language that the processor can
directly understand.

ONE MARKS

[Link] is the father of computer?


A] Charles Newman B] Charles Babbage

C] Henry Babbage D] Henry luce

[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

3.A computer consists of

A] A central processing unit

B] A memory

C] Input and output unit

D] All of the above

Answer: All of the above

[Link] part of the computer is used for calculating and comparing?

A]Disk unit

B]Control unit

3]ALU

4]Modem

5]None of the above

[Link] many different forms of computer architecture are there?

A]Five

B]Three

C]Two

D]Four
E]None of the above

[Link] part of the computer is used for calculating and comparing?

A]Disk unit

B]Control unit

C]ALU

D]Modem

E]None of the above

[Link] of the following devices is widely used for playing games on the
computer?

A]scanner

B]touchpad

C]keyboard

D]joystick

[Link] itself has following ___________ components

A. 2

B. 3

C. 4

D. 5

[Link] unit can store instructions, data, and intermediate results?

A. Arithmetic Logic Unit

B. Control Unit

C. Storage Unit

D. All of the above


[Link] controls the operation of all parts of the computer.

[Link]

B. FALSE

C. Can be true or false

[Link] main memory of a computer is made using which of the following


techniques?

[Link]

[Link]

[Link]-conductor

[Link] tube

[Link] the following, which is considered the main memory?

[Link]

[Link]

[Link] memory

[Link] card

[Link] of the above

[Link] of the following is a Permanent Memory in the computer?

[Link]

[Link]

[Link]

[Link] ROM

14. It is also called as online input device.


A. Webcamera
B. Joystick
C. Keyboard
D. Mouse
15. User communicates with a computer with the help of which devices?
A. Input device
B. Output device
C. Software device
D. Both a and b
16. Which of the following is not a pointing device?
A. Mouse
B. Joystick
C. Light pen
D. Digitizer

[Link], Shift, and Alt are known as _ _ _ _ _ _ _keys.


A. function
B. modifier
C. alphanumeric
D. adjustment
[Link] of the following are not input devices?
A. Webcam and Microphone
B. Bar Code Reader and Smart Card Reader
C. Optical Character Reader and Optical Mark Recognition
D. Monitor and Printer
[Link] stands for?
A. Cathode-Ray Tracks
B. Clarity-Ray Tube
C. Cathode-Ray Tube
D. None of the above
20. How many types of printers?
A. 2
B. 3
C. 4
D. 5
21. Monitors are also known as ?
A. ADU
B. ALU
C. VCU
D. VDU
[Link] printers print the characters without using the ribbon
A. TRUE
B. FALSE
C. Can be true or false

23. The MICR stands for


A. Magnetic Ink Card Reader
B. Magnetic Ink Code Recognition
C. Meta Ink Character Recognition
D. None of these
24.A __________ can be defined as a small, relatively inexpensive computer
designed for an individual user.
A. Workstation
B. Personal Computer
C. Mini Computer
D. Main Frame

[Link] computers are designed as single-user systems.


A. TRUE
B. FALSE
C. Can be true or false

26.______computers are lower to mainframe computers in terms of speed and


storage capacity.
A. Super
B. Mini
C. Mainframes
D. Hybrid

27._____________ are used for solving complex application such as Global


Weather Forecasting.
A. Super Computers
B. Public computers
C. Mobile computers
D. Hybrid computers

[Link] type of computer can handle analog as well as digital data?


A. Digital
B. Analog
C. Hybrid
D. All of these

[Link] computer works on data in 0's and 1's.


A. Digital computer
B. Hybrid computer
C. Physical computer
D. Analog computer

[Link] physical devices of a computer :


A. Software
B. Package
C. Hardware
D. System Software

30. Which of the following is designed to control the operations of a computer?


A. Application Software
B. System Software
C. Utility Software
D. User

[Link] of the following is not an example of system software?


A. Language Translator
B. Utility Software
C. Communication Software
D. Word Processors

32.A person who designs the programs in a software package is called :


A. User
B. Software Manager
C. System Developer
D. System Programmer

33.___________________ is designed to solve a specific problem or to do a


specific task.
A. Application Software
B. System Software
C. Utility Software
D. User

[Link] is used as a translator for?


A. Low level language
B. High Level Language
C. COBOL
D. C

[Link] of the following is an example of application software?


A. Security software
B. Command system
C. Operating system
D. CAD/CAM system
Ans: D)CAD/CAM system

[Link] item is called the “heart of a word processing system”?


A. Input devices
B. Data file
C. Floppy disk drive
D. Software

[Link] is the alternative name for application software?


A. End-user software
B. Utility software
C. Specific software
D. All of these

38.4GL is an example of ______________ processing.


A. White Box
B. Black Box
C. Functional
D. Both Black Box & Functional
[Link] is a major advantage of using a 4GT Model for producing small scale
products, applications or programs ?
A. Improved productivity of software engineers
B. Reduction in software development time
C. 4GT helped by CASE tools and code generators offers a credible solution to
many software problems
D. None of the mentioned

[Link] a fourth generation language (4GL) from the given below.


A. FORTRAN
B. COBOL
C. Unix shell
D. C++

41. C language is a successor to which language?


[Link]
[Link]
C.C++
D.B

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 the following error can a compiler check?


A. Syntax Error
B. Logical Error
C. Both Logical and Syntax Error
D. Compiler cannot check errors

[Link] of the following is a limitation of computer?


A. Inability to think
B. Shortfall capacity
C. Reliability
D. Accuracy

46.____________has smallest storage capacity


A. Floppy disk
B. Zip disk
C. Hard disk
D. CD
[Link] of the following device is not a type of output device?
A. Printer
B. Monitor
C. Scanner
[Link]
[Link] is the primary function of a computer's central processing unit
(CPU)?
A. To store data
B. To process data
C. To transmit data
D. To display data
[Link] type of computer memory is considered "volatile"?
A. Hard disk drive
B. Random access memory (RAM)
C. Read-only memory (ROM)
D. Solid state drive
[Link] type of computer security measure is used to protect against
unauthorized access to a network or computer system?
A. Firewall
B. Anti-virus
C. Encryption
[Link]
FIVE MARKS

[Link] of computer?
[Link] of Computers?
[Link] is software? and explain its types?
[Link] programming Languages?
[Link] is Computer ? types of Computers?

TEN MARKS

[Link] discuss about harware? and its components?


[Link] about features of 4GL and 5GL?

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

used for representing simple values such as integers, float,


Types
characters, etc.

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.

Integer Data Type


 The integer datatype in C is used to store the whole numbers without
decimal values. Octal values, hexadecimal values, and decimal values can
be stored in int data type in C.

Range: -2,147,483,648 to 2,147,483,647


Size: 4 bytes
Format Specifier: %d
Float Data Type
 In C programming float data type is used to store floating-point values.
Float in C is used to store decimal and exponential values. It is used to store
decimal numbers (numbers with floating point values) with single precision.
Range: 1.2E-38 to 3.4E+38
Size: 4 bytes
Format Specifier: %f

Double Data Type


 A Double data type in C is used to store decimal numbers (numbers with
floating point values) with double precision. It is used to define numeric
values which hold numbers with decimal values in C.
 The double data type is basically a precision sort of data type that is capable
of holding 64 bits of decimal numbers or floating points. Since double has
more precision as compared to that float then it is much more obvious that it
occupies twice the memory occupied by the floating-point type. It can easily
accommodate about 16 to 17 digits after or before a decimal point.
Range: 1.7E-308 to 1.7E+308
Size: 8 bytes
Format Specifier: %lf
Character Data Type
 Character data type allows its variable to store only a single character. The
size of the character is 1 byte. It is the most basic data type in C. It stores a
single character and requires a single byte of memory in almost all
compilers.
Range: (-128 to 127) or (0 to 255)
Size: 1 byte
Format Specifier: %c

Void Data Type


 The void data type in C is used to specify that no value is present. It does
not provide a result value to its caller. It has no values and no operations. It
is used to represent nothing. Void is used in multiple ways as function return
type, function arguments as void, and pointers to void.

Input

 To get user input, you can use the scanf() function


 printf() is used to output values in C.

Program

// Create an integer variable that will store the number we get from the user
int myNum;

// Ask the user to type a number


printf("Type a number: \n");

// Get and save the number the user types


scanf("%d", &myNum);

// Output the number the user typed


printf("Your number is: %d", 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];

printf("Type your full name: \n");


fgets(fullName, sizeof(fullName), stdin);

printf("Hello %s", fullName);

// Type your full name: John Doe


// Hello John Doe

 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

Single User Programming


 It is usually done by a single person for his personal use. This technique is
suitable even for small offices.

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

 The C Arithmetic Operators are of two types based on the number of


operands they work. These are as follows:
1. Binary Arithmetic Operators
2. Unary Arithmetic Operators

Binary Arithmetic Operators in C


 The C binary arithmetic operators operate or work on two operands. C
provides 5 Binary Arithmetic Operators for performing arithmetic functions
which are as follows:

Name of the
Operator Operator Arithmetic Operation Syntax

+ Addition Add two operands. x+y

Subtract the second operand from the


– Subtraction first operand. x–y

* Multiplication Multiply two operands. x*y

/ Division Divide the first operand by the second x/y


Name of the
Operator Operator Arithmetic Operation Syntax

operand.

Calculate the remainder when the first


% Modulus operand is divided by the second x%y
operand.

2. Unary Arithmetic Operators in C

 The unary arithmetic operators operate or work with a single operand. In C,


we have two unary arithmetic operators which are as follows:

Operator Symbol Operation Implementation

Decrement Decreases the integer value of the


— –h or h–
Operator variable by one.

Increment Increases the integer value of the


++ ++h or h++
Operator variable by one.

Unary Plus
+ Returns the value of its operand. +h
Operator

Unary Minus Returns the negative of the value


– -h
Operator of its operand.

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

 Operators, we may have some problems as to how exactly does it get


executed. For example, does the expression 2 * x - 3 * y correspond to (2x)-
(3y) or to 2(x-3y)? Similarly, does A / B * C correspond to A / (B * C) or to
(A / B) * C? To answer these questions satisfactorily one has to understand
the ‘hierarchy’ of operations.
 The priority or precedence in which the operations inan arithmetic statement
are performed is called the hierarchy of operations. The hierarchy of
commonly used operators is shown in Figure 1.8.

Program development cycle


 When we want to develop a program by using any programming language,
we have to follow a sequence of steps. These steps are called phases in
program development.
 The program development life cycle is a set of steps or phases which are used
to develop a program in any programming language.
Phases of program development
Program development life cycle contains 6 phases, which are as follows −
 Problem Definition.
 Problem Analysis.
 Algorithm Development.
 Coding & Documentation.
 Testing & Debugging.
 Maintenance.
These six phases are depicted in the diagram given below –

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

 Structured programming is a programming paradigm aimed at improving the


clarity, quality, and development time of a computer program by making
extensive use of the structured control flow constructs of selection
(if/then/else) and repetition (while and for), block structures, and subroutines.

What is an Algorithm?

 An algorithm is a process or a set of rules required to perform calculations or


some other problem-solving operations especially by a computer.
 The formal definition of an algorithm is that it contains the finite set of
instructions which are being carried in a specific order to perform the specific
task.
 It is not the complete program or code; it is just a solution (logic) of a
problem, which can be represented either as an informal description using a
Flowchart or Pseudocode.

Characteristics or features of an Algorithm

 Finiteness, means it must always terminate after a finite number of steps.


 Definiteness, means each step must be precisely defined and clear.
 Input, means it has zero or more inputs, i.e., an algorithm can run without
taking any input.
 Output, means it has one or more outputs, i.e., an algorithm must produce
atleast one output.
 Effectiveness, means it is also generally expected to be effective.

Advantages of Algorithms

1. Efficiency – Algorithms help to automate repetitive tasks and make them


more efficient, which saves time and resources.
2. Accuracy – Algorithms can be designed to be highly accurate, which helps to
reduce errors and improve decision-making.
3. Scalability – Algorithms can be easily scaled up or down to handle large or
small amounts of data, making them a versatile tool for solving a wide range
of problems.
4. Objectivity – Algorithms are based on set of rules and instructions, which
can help to eliminate subjective bias and improve fairness in decision-
making.
5. Learning and Improving – Algorithms can be designed to learn and
improve over time, making them adaptable to changing circumstances and
new information.

Disadvantages of Algorithms

1. Complexity – Algorithms can be complex and difficult to understand,


making it challenging for people without technical expertise to interpret or
analyze them.
2. Bias – Algorithms can perpetuate or amplify biases present in the data used to
train them, which can lead to unfair or discriminatory results.
3. Lack of transparency – Algorithms can be opaque, meaning that it’s hard to
see how they arrived at a particular decision, which can make it difficult to
identify and fix errors or biases.
4. Security – Algorithms can be vulnerable to hacking, which can lead to
security breaches and the loss of sensitive information.
5. Job replacement – Algorithms can automate repetitive tasks and make them
more efficient, which can lead to job loss for people who perform those tasks.

Flow chart

 A flowchart is a type of diagram that represents a workflow or process. A


flowchart can also be defined as a diagrammatic representation of an
algorithm, a step-by-step approach to solving a task.

Advantages Of Flowchart

 It is a convenient method of communication.


 It indicates very clearly just what is being done, where a program has logical
complexities.
 A key to correct programming.
 It is an important tool for planning and designing a new system.
 It clearly indicates the role played at each level.
 It saves inconveniences in the future and serves the purpose of documentation
for a system.
 It provides an overview of the system and also demonstrates the relationship
between various steps.
 Facilitates troubleshooting.
 It promotes logical accuracy.
 It makes sure that no logical path is left incomplete without any action being
taken.

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

 Definition: Pseudo code is an informal way of programming description that


does not require any strict programming language syntax or underlying
technology considerations.
 It is used for creating an outline or a rough draft of a program. Pseudo code
summarizes a program's flow, but excludes underlying details.

How to write a Pseudo-code?

1. Arrange the sequence of tasks and write the pseudocode accordingly.


2. Start with the statement of a pseudo code which establishes the main goal or the
aim.
Example:
This program will allow the user to check
the number whether it's even or odd.

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

 The pseudocode in C is an informal way of writing a program for better


human understanding. It is written in simple English, making the complex
program easier to understand.
 Pseudocode cannot be compiled or interpreted. It doesn't follow the
programming language's syntax; it is thus written in pseudocode so that
any programmers or non-programmers can easily understand it.

Consider the following source code example:

 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

 Convert pseudocode to comments

 Update comments as program changes

 Add summary/high-level instructions

 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.

Using pseudocode in testing our projects, we came to the following


conclusions:

o it is visual;

o it’s convenient: pseudocode is very easy to maintain;

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.

 There are 5 types of error in C:


1. Syntax Errors
2. Runtime Errors
3. Logical Errors
4. Linked Errors
5. Semantic Errors
1. Syntax Errors
 These are also referred to as compile-time errors. These errors have
occurred when the rule of C writing techniques or syntaxes has been
broken. These types of errors are typically flagged by the compiler
prior to compilation.
Example: In the below program we are getting an error because of a
missing semicolon at the end of the output statement (printf()) called syntax
error.
2. Runtime Errors
 This type of error occurs while the program is running. Because this is
not a compilation error, the compilation will be completed
successfully. These errors occur due to segmentation fault when a
number is divided by division operator or modulo division operator.
Example: Let us consider an array of length 5 i.e. array[5], but during
runtime, if we try to access 10 elements [Link][10] then we get
segmentation fault errors called runtime errors. Giving only an array length
of 5

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

 Program design consists of the steps a programmer should do before


they start coding the program in a specific language. These steps when
properly documented will make the completed program easier for other
programmers to maintain in the future. There are three broad areas of
activity:
o Understanding the Program
o Using Design Tools to Create a Model
o Develop Test Data

Modular programming

 Modular programming is defined as a software design technique that


focuses on separating the program functionality into independent,
interchangeable methods/modules.
 Each of them contains everything needed to execute only one aspect of
functionality.

Talking of modularity in terms of files and repositories, modularity can be on


different levels -

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.

Examples of modular programming languages - All the object-oriented


programming languages like C++, Java, etc., are modular programming languages.

Module

A module is defined as a part of a software program that contains one or more


routines. When we merge one or more modules, it makes up a program. Whenever a
product is built on an enterprise level, it is a built-in module, and each module
performs different operations and business. Modules are implemented in the
program through interfaces. The introduction of modularity allowed programmers to
reuse prewritten code with new applications. Modules are created and merged with
compilers, in which each module performs a business or routine operation within
the program.

For example - SAP(System, Applications, and Products) comprises large modules


like finance, payroll, supply chain, etc. In terms of softwares example of a module is
Microsoft Word which uses Microsoft paint to help users create drawings and
paintings.

Advantages of modular programming

The following are advantages of modular programming -

o Code is easier to read - Working on modular programming makes code


easier to read because functions perform different tasks as compared to
monolithic codes. Sometimes modular programming can be a bit messy if we
pass arguments and variables in different functions. The use of modules
should be done in a sensible manner so as to avoid any problem. Functions
should be neat, clean, and descriptive.
o Code is easier to test - In software, some functions perform fewer tasks and
also functions that perform numerous tasks. If the software is easily split
using modules, it becomes easier to test. We can also focus on the riskier
functions during testing and need more test cases to make it bug-free.
o Reusability - There are times where a piece of code is implemented
everywhere in our program. Instead of copying and pasting it, again and
again, modularity gives us the advantage of reusability so that we can pull our
code from anywhere using interfaces or libraries. The concept of reusability
also reduces the size of our program.
o Faster fixes - Suppose there is an error in the payment options in any
application, and the bug needs to be removed. Modularity can be a great help
because we know that there will be a separate function that will contain the
code of payments, and only that function will only be rectified. Thus using
modules to find and fixing bugs becomes much more smooth and
maintainable.
o Low-risk update - In modular programming, a defined layer of APIs protects
things that use it from making changes inside the library. Unless there is a
change in the API, there is a low risk for someone's code-breaking. For
example, if you didn't have explicit APIs and someone changed a function
they thought was only used within that same library (but it was used
elsewhere), they could accidentally break something.
o Easy collaboration - Different developers work on a single piece of code in
the team. There are chances of conflicts when there's a git merge. This
conflict can be reduced if the code is split between more functions, files,
repos, etc. We can also provide ownership to specific code modules, where a
team member can break them down into smaller tasks.

Disadvantages of modular programming

The following are disadvantages of modular programming -

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.

 Modular programming is an ancient concept, but it is still a buzzword


among developers. For a developer, one must learn to code in modules.
There are times when we need to retrieve any code, make a dummy
module for testing, and minimize the risk factors. Modular
programming is bagged with such features making it essential.

ONE MARKS

1. Which of the following is not a data type?


a) Symbolic Data
b) Alphanumeric Data
c) Numeric Data
d) Alphabetic Data

2.*@Ac# is a type of ________________ data.


a) Symbolic
b) Alphanumeric
c) Alphabetic
d) Numeric

3. Which of the following is not a basic data type in C language?


a) float
b) int
c) real
d) char

4. BOOLEAN is a type of data type which basically gives a tautology or fallacy.


a) True
b) False

[Link] does FORTRAN stands for?


a) Formula Transfer
b) Formula Transformation
c) Formula Translation
d) Format Transformation

[Link] of the following is not a valid declaration in C?


1. short int x;
2. signed short x;
3. short x;
4. unsigned short x;
OPTION
a)3 and 4
b)2
c)1
d)All are valid

[Link] C, sizes of an integer and a pointer must be same.


a)True
b)False

8. What is the precedence of arithmetic operators (from highest to lowest)?


a) %, *, /, +, –
b) %, +, /, *, –
c) +, -, %, *, /
d) %, +, -, *, /
9. Which of the following is not an arithmetic operation?
a) a * = 10;
b) a / = 10;
c) a ! = 10;
d) a % = 10;

10. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf("%d", c);
}
a) 15
b) 16
c) 15.6
d) 10

11. What will be the output of the following C code?


#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
a) Syntax error
b) 1
c) 10
d) 5

[Link] operators has the lowest priority?


a)++
b)%
c)+
d)||
e)&&

[Link] of the following is a valid expression in C?


a)intbasic_pay = 23000;
b)intbasic_pay = 23,000;
c)int basic pay = 23000;
d)int $basic_pay = 23000;

[Link] among the following operator has the highest priority?


a)Comma operator
b)Conditional operator
c)Relational operator
d)Unary plus operator

16. The symbol denotes _______

a) I/O
b) Flow
c) Terminal
d) Decision

17. The process of drawing a flowchart for an algorithm is called __________


a) Performance
b) Evaluation
c) Algorithmic Representation
d) Flowcharting

18. The following box denotes?

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

20. Which of the datatypes have size that is variable?


a) int
b) struct
c) float
d) double
21. A flowchart that outlines the main segments of a program.
a) Queue
b) Macro
c) Micro
d) Union

[Link] computer science, algorithm refers to a pictorial representation of a


flowchart.
a) True
b) False

22. A box that can represent two different conditions.


a) Rectangle
b) Diamond
c) Circle
d) Parallelogram

[Link] of the following is not an advantage of a flowchart?


a) Better communication
b) Efficient coding
c) Systematic testing
d) Improper documentation

24.A detailed flowchart is called ______


a) Stack
b) Macro
c) Micro
d) Union

25.A flowchart that outlines the main segments of a program.


a) Queue
b) Macro
c) Micro
d) Union

[Link] of the following in a program planning tool?


a) Sequential
b) decision
c) Pseudo code
b) Both B& C

27 Which of the datatypes have size that is variable?


a) int
b) struct
c) float
d) double

[Link] process of drawing a flowchart for an algorithm is called __________


a) Performance
b) Evaluation
c) Algorithmic Representation
d) Flowcharting
[Link] the statement language ______________ while writing a pseudo code.
a) Dependent
b) Independent
c) Case sensitive
d) Capitalized
[Link] initial keyword – This is a rule while writing a pseudo code.
a) True
b) False
31.______________ is used to show hierarchy in a pseudo code.
a) Indentation
b) Curly Braces
c) Round Brackets
d) Semicolon
32.____________ begins with lower case letters.
a) Keywords
b) Variables
c) Tokens
d) Functions
33.A program logic written in an ordinary language depicting a structure
similar to computer instructions is known as
A) Algorithms
B) Programs
C) Flowcharts
D) Pseudocodes

[Link] of the following Comments are used in C Programming ?


[A] Single Line Comment
[B] None of these
[C] Enhanced Comment
[D] Multiple Line Comment

[Link] in C Programming are ignored by ________.


[A] Interpreter
[B] None of these
[C] Compiler
[D] Browser

[Link] line comments are denoted by _____.


[A] /*
[B] //
[C] \\\\
[D] */
[Link] of the following is appropriate position for writing comment in C
Programming ?
[A] before calling the main function
[B] before header file section
[C] before variable declaration section
[D] anywhere in the code

[Link] stands for


a) Software Development Life Cycle
b) System Development Life cycle
c) Software Design Life Cycle
d) System Design Life Cycle
[Link] way of commenting a single line is.?
A) /*printf("Hello C..");
printf("How are you.");
B) //printf("Hello C..");
printf("How are you.");
C) /*printf("Hello C..");
printf("How are you.");*/
D) /printf("Hello C..");/
printf("How are you.");
[Link] are the types of Constants in C Language.?
A) Primary Constants
B) Secondary Constants
C) Basic Constants and Advanced Constants
D) Primary Constants and Secondary Constants
[Link] error occurs when a result is undefined for a given argument value?
a) significance loss
b) underflow
c) overflow
d) domain
[Link] among the following are the fundamental arithmetic operators, i.e,
performing the desired operation can be done using that operator only?
a) +, –
b) +, -, %
c) +, -, *, /
d) +, -, *, /, %

[Link] will be the output of the following C code?


#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = a == (b + c);
printf("%d", d);
}
a) Syntax error
b) 1
c) 10
d) 5
[Link] will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 10;
double b = 5.6;
int c;
c = a + b;
printf("%d", c);
}
a) 15
b) 16
c) 15.6
d) 10
[Link] cannot do anything without a
(A) Program
(B) Output device
(C) Chip
(D) Memory

[Link] is the output of this program?


void main()
{
int x = 10;
float x = 10;
printf("%d", x)
}
A. Compilations Error
B. 10
C. 10
D. 10.1

[Link] is the output of this program?


#include <stdio.h>
int var = 20;
int main()
{
int var = var;
printf("%d ", var);
return 0;
}
A. Garbage Value
B. 20
C. Compiler Error
D. None of these

48.__________ refers to the process of checking your algorithm while seated at


your desk.
[Link]-checking
[Link]-checking
[Link]-checking
[Link]-checking

[Link] of the following is not a valid representation in bits?


a) 8-bit
b) 24-bit
c) 32-bit
d) 64-bit

[Link] keyword typedef is used to


[A] create a type of function
[B] define the type of function
[C] define the type of a variable
[D] create a new datatype name

[Link] an algorithm is written in the form of a programming language, it


becomes a _________
a) Flowchart
b) Program
c) Pseudo code
d) Syntax Read more on [Link]

[Link] process of drawing a flowchart for an algorithm is called __________


a) Performance
b) Evaluation
c) Algorithmic Representation
d) Flowcharting

FIVE MARKS

[Link] is data types ?and its types?

2. Explain Methods of data processing?

[Link] about Arithmetic operators?

[Link] Pseudo Code?

[Link] Comment line? and types?


10 MARKS
[Link] Explain about Algorithms?

[Link] about Flowcharts?

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.

 In this case, a programmer would use an elseif structure. The following


screenshot show this example in MATLAB.

 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.

Several Alternatives in Selection Structures.

 At times you need to create selection structures that can select from many
alternatives. Such selection structure is known as multiple-alternative
selection structures.

 For example, a selection structure that displays message based on a letter


grade entered by the user.

Applications of Selection Structures

 Selection Structure. Use to make a decision or comparison and then, based on


the result of that decision or comparison, to select one of two paths.

 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.

Here is the table of relational operators in C language


Operators Operator Name

== Equal to

> Greater than

< Less than

!= Not equal to

>= Greater than or equal to


Operators Operator Name

<= Less than or equal to

Here is an example of relational operator in C language


Example
#include<stdio.h>
intmain(){
int x =10;
int y =28;
if(x==y)
printf("Both variables are equal
");
if(x>y)
printf("x is greater than y
");
if(x<y)
printf("x is less than y
");
if(x!=y)
printf("x is not equal to y
");
if(x<=y)
printf("x is lesser or equal to y
");
if(x>=y)
printf("x is greater or equal to y
");
return0; }
Output
x is less than y
x is not equal to y
x is lesser or equal to y
Logical Operators
 Logical operators are used to perform logical operations. It returns 0 or 1
based on the result of condition, whether its true or false. These operators are
used for decision making in C language.
Here is the table of logical operators in C language,
Operators Meaning of Results
Operators

&& Logical AND True when all operands are


true

|| Logical OR True only if either one


operand is true

! Logical NOT True when operand is zero

Here is an example of logical operators in C language,


Example
#include<stdio.h>
intmain(){
int x =10;
int y =28;
int a =15;
int b =20;
if(x<y && a==b)
printf("x is less than y AND a is equal to b
");
if(x<y || a==b)
printf("x is less than y OR a is equal to b
");
if(!x)
printf("x is zero
");
return0;
}
Output
x is less than y OR a is equal to b
Repetition structures
 A program loop is defined as a block of statements, which are frequently
executed for certain number of times even though these statements come into
view once in a program.
 This loop is also known as iterative structure or repetitive structure.
expression-1;do{statement;expression-3;}while(expression-2);

Counter Controlled Loop

 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.

Consider the code snippet

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.

Syntax of Nested loop

Outer_loop
{
Inner_loop
{
// inner loop statements.
}
// outer loop statements.
}

Nested for loop

 The nested for loop means any type of loop which is defined inside the 'for'
loop.

 Syntax

for (initialization; condition; update)


{
for(initialization; condition; update)
{
// inner loop statements.
}
// outer loop statements.
}

Nested while loop

 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);

Applications of Repetition Structures


 Examples of such repetition include continual checking of user data entries
until an acceptable entry, such as a valid password, is made; counting and
accumulating running totals; and recurring acceptance of input data and
recalculation of output values that only stop upon entry of a designated value.
 The applications examined so far have illustrated the programming concepts
involved in input, output, assignment, and selection capabilities.
 By this time you should have gained enough experience to be comfortable
with these concepts and the mechanics of implementing them using Visual
Basic.
 However, many problems require a repetition capability, in which the same
calculation or sequence of instructions is repeated, over and over, using
different sets of data.
 Examples of such repetition include continual checking of user data entries
until an acceptable entry, such as a valid password, is made; counting and
accumulating running totals; and recurring acceptance of input data and
recalculation of output values that only stop upon entry of a designated value.
 This chapter explores the different methods that programmers use to construct
repeating sections of code and how they can be implemented in Visual Basic.
 A repeated procedural section of code is commonly called a loop, because
after the last statement in the code is executed, the program branches, or
loops back to the first statement and starts another repetition. Each repetition
is also referred to as an iteration or pass through the loop.
ONE MARKS
[Link] logical operator sequence points?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard

[Link] is the result of logical or relational expression in C?


a) True or False
b) 0 or 1
c) 0 if an expression is false and any positive number if an expression is true
d) None of the mentioned

[Link] will be the final value of d in the following C code?


#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = b + c == a;
printf("%d", d);
}
a) Syntax error
b) 1
c) 5
d) 10

[Link] among the following is NOT a logical or relational operator?


a) !=
b) ==
c) ||
d) =

[Link] operators cannot be used on ____


a) structure
b) long
c) strings
d) float

[Link] the output of the given C program.


#include<stdio.h>
int main()
{
int a;
a = 'a' > 'A';
printf("%d",a);
return 0;
}
a) Garbage Value
b) 0
c) 1
7. Which operators are used to compare the values of operands to produce
logical value in C language?
[A] Logical operator
[B] Relational operator
[C] Assignment operator
[D] None of the above

[Link] are built-in data structures in C programming?


[A] Arrays
[B] Structures
[C] Files
[D] All of the above

[Link] expression contains relational, assignment and arithmetic operators. If


parenthesis are not specified, the order of evaluation of the operators would be:
[A] assignment, arithmetic, relational
[B] relational, assignment, arithmetic
[C] assignment, relational, arithmetic
[D] arithmetic, relational, assignment

[Link] a right C Statement.


A) Loops or Repetition block executes a group of statements repeatedly.
B) Loop is usually executed as long as a condition is met.
C) Loops usually take advantage of Loop Counter
D) All the above.
[Link] in C Language are implemented using.?
A) While Block
B) For Block
C) Do While Block
D) All the above

12. Which loop is faster in C Language, for, while or Do While.?


A) for
B) while
C) do while
D) All work at same speed

13. Choose correct C while loop syntax.


A) while(condition)
{
//statements
}
B) {
//statements
}while(condition)
C) while(condition);
{
//statements
}
D) while()
{
if(condition)
{
//statements
}
}

[Link] a correct C for loop syntax.


A) for(initalization; condition; incrementoperation)
{
//statements
}
B) for(declaration; condition; incrementoperation)
{
//statements
}
C) for(declaration; incrementoperation; condition)
{
//statements
}
D) for(initalization; condition; incrementoperation;)
{
//statements
}

[Link] a correct C do while syntax.


A)
dowhile(condition)
{
//statements
}
B)
do while(condition)
{
//statements
}
C)
do
{
//statements
}while(condition)
D)
do
{
//statements
}while(condition);

[Link] is the output of C Program.?


int main()
{
while(true)
{
printf("RABBIT");
break;
}

return 0;
}
A) RABBIT
B) RABBIT is printed unlimited number of times.
C) No output
D) Compiler error.

[Link] is the output of C Program.?

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.

[Link] is the output of C Program.?

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.

[Link] is the output of C Program.?


int main()
{
int a=5;

while(a >= 3);


{
printf("RABBIT\n");
break;
}
printf("GREEN");

return 0;
}
A) GREEN
B) RABBIT

GREEN
C) RABBIT is printed infinite times
D) None of the above

[Link] is the output of C Program.?

int main()
{
int a=25;

while(a <= 27)


{
printf("%d ", a);
a++;
}

return 0;
}
A) 25 25 25
B) 25 26 27
C) 27 27 27
D) Compiler error

[Link] is the output of C Program.?


int main()
{
int a=32;

do
{
printf("%d ", a);
a++;
}while(a <= 30);

return 0;
}
A) 32
B) 33
C) 30
D) No Output

[Link] a correct C Statement.


A) a++ is (a=a+1) POST INCREMENT Operator
B) a-- is (a=a-1) POST DECREMENT Opeartor

--a is (a=a-1) PRE DECREMENT Opeator


C) ++a is (a=a+1) PRE INCRMENT Operator
D) All the above.

[Link] is the output of C Program.?

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

24.1. The C code ‘for(;;)’ represents an infinite loop. It can be terminated by


___________
a) break
b) exit(0)
c) abort()
d) terminate

25.A loop within another loop statement is called


A) Inner structure
B) Nested loop
C) Complex loop
D) Infinite loop

26. Which of the following loop can be used as outer loop ?


A) while
B) do while
C) for
D) All of these

[Link] use __________ known as loops.


a) Repetition structure
b) Conditional structure
c) Goto
d) Unconditional structure

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

29. The requirement for repeating the instructions is referred to as the


__________
a) Looping condition
b) Conditional statement
c) Iterative statement
d) Initialization statement

30. In a __________ loop the condition is evaluated before the instructions


within the loop are processed.
a) Posttest
b) Pretest
c) Conditional loop
d) Unconditional loop

[Link] a __________ loop the condition is evaluated before the instructions


within the loop are processed.
a) Posttest
b) Pretest
c) Conditional loop
d) Unconditional loop

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

33. The __________ in a Do…Loop statement can contain variables, methods,


constants, properties and operators.
a) Exit statement
b) Condition
c) Statement
d) Iteration 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] continue statment cannot be used with ________


a) for
b) while
c) do while
d) switch

[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

[Link] select case statement ends with ____


a) Select End clause
b) End Select clause
c) End clause
d) Select clause

[Link] is an easier alternative of multiple-alternative selection structure?


a) Single-alternative selection structure
b) Multipath selection structure
c) Select case Statement
d) Multiway-alternative selection structure

40.____ must be the last clause in the Select Case statement.


a) Case Else
b) Case expnumber
c) Case seletorExpression
d) Case default
[Link] of the following is the advantage of the array data structure?
a)Elements of mixed data types can be stored.
b)Easier to access the elements in an array
c)Index of the first element starts from 1.
d)Elements of an array cannot be sorted

[Link] a selection structure’s true part or false part contains another


selection structure, the inner selection structured is referred to as ____
a) Implicit selection structure
b) Inner selection structure
c) Outer selection structure
d) Nested selection structure

[Link] common error that occur in selection structure is ____


a) Logical error
b) Syntactical error
c) Segmentation fault
d) Compiler error

44.A nested selection structure can be contained in ________ of another


selected structure.
a) Only in the truth part
b) Only in the false part
c) Either in truth or in false part
d) Both in truth and in false part
[Link] the following scenarios, when will you use selection sort?
a) The input is already sorted
b) A large file has to be sorted
c) Large values need to be sorted with small keys
d) Small values need to be sorted with large keys

[Link] or Abbreviate ASCII with regard to C Language.


A) Australian Standard Code for Information Interchange
B) American Standard Code for Information Interchange
C) American Symbolic Code for Information Interchange
D) Australian Symbolic Code for Information Interchange

[Link] is the output of C Program.?


int main()
{
int a=10,b=20;
if(a==9 AND b==20)
{
printf("Hurray..");
}

if(a==10 OR b==21)
{
printf("Theatre");
}
return 0;
}
A) Theatre
B) Hurray

Theatre
C) No output
D) Compiler error

[Link] of the following is an exit controlled loop?


a)While loop.
b)For loop.
c)do-while loop.
d)None of the above

[Link] of the following are not standard header files in C?


a)stdio.h
b)stdlib.h
c)conio.h
d)None of the above.

[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

 Numerical data, also known as quantitative data, is data that you


typically present in number form, and it doesn't include any language
or descriptive form. It's always measurable, and you can add it
together.
 You can perform mathematical and arithmetical operations on it, and
you can express it in decimal or fraction form. It's can be helpful, for
example, in presenting information about height, weight and age.

Types of numerical 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:

 You can describe continuous data as everything in-between an interval. For


example, these are measurements rather than discrete values. You can further
divide this countably finite and, in some cases, infinite data into interval and
ratio 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

 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.

Char Data Types

 Fixed-length char strings can contain any printing or non-printing character,


and the null character ('\0'). Char strings are padded with blanks to the
declared length.
 Leading and embedded blanks are significant when comparing char strings.
For example, the following char strings are considered different:
 'A B C'
'ABC'
 Length is not significant when comparing char strings; the shorter string is
(logically) padded to the length of the longer. For example, the following char
strings are considered equal:
 'ABC'
'ABC '

Varchar Data Types

 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').

Long Varchar Data Types

 The intrinsic Ingres DBMS long varchar data type is supported in


OpenROAD through the LongVarcharObject system class. For more
information, see LongVcharObject Class.

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:

 int is a type of data value.


 Data items stored in an array are known as elements.
 The location or placing of each element has an index value.
Important: Array can store only the same type of data items. From the below
example you can see how it works:

 In the array a, we have stored all integral values (same type)


 In the array b, we have stored all char values (same type)
 In the array c, there is integral, float, char all types of values and this is not
something an array can store so, option 3 is wrong because an array cannot
store different types of values.

Declaration Syntax of Array:


VariableTypeVariableName[Sequence of Elements];
Example 1: For integral value
int A[10];
Here 10 means, this array A can have 10 integer elements.

2 5 8 44 21 11 7 9 3 1

Example 2: For character value


char B[10];
This array B can have 10 character elements.

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

One -Dimensional Arrays


 A one-dimensional array is a kind of linear array. It involves single sub-
scripting. The [] (brackets) is used for the subscript of the array and to declare
and access the elements from the array.
Syntax: DataTypeArrayName [size];
For example: int a[10];

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:

 In an array, it is essential to identify the number of elements to be stored.


 It is a static structure. It means that in an array, the memory size is fixed.
 When it comes to insertion and deletion, it is a bit difficult because the
elements are stored sequentially and the shifting operation is expensive.
Strings

 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.

 A string is actually a one-dimensional array of characters in C language.


These are often used to create meaningful and readable programs.

 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

end of the string.

Declaring and Initializing a string variables:

// valid

char name[13] = "StudyTonight";

char name[10] = {'c','o','d','e','\0'};

// Illegal

char ch[3] = "hello";

char str[4];

str = "hello";

String Input and Output:

 %s format specifier to read a string input from the terminal.


 But scanf() function, terminates its input on the first white space it
encounters.

 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);

String Handling Functions:

 C language supports a large number of string handling functions that can be


used to carry out many of the string manipulations. These functions are
packaged in the string.h library. Hence, you must include string.h header file
in your programs to use these functions.

The following are the most commonly used string handling functions.

Method Description

strcat() It is used to concatenate(combine) two strings

strlen() It is used to show the length of a string


strrev() It is used to show the reverse of a string

strcpy() Copies one string into another

strcmp() It is used to compare two string

strcat() function in C:

 The strcat() will add the string "world" to "hello" [Link] = helloworld.

strlen() and strcmp() function:

 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.

strrev() function:It is used to reverse the given string expression

ONE MARKS

[Link] you group together related variables, the group is referred to as


_______

a) Array

b) List
c) Relation

d) Variable group

[Link] array in a program is efficient because ______

a) It shortens the program.

b) The program compiles faster

c) Number of variables are reduced.

d) Data is accessed faster

[Link] in an array can be distinguished using _____ number.

a) Reference

b) Subscript

c) Array

d) ID

[Link] array is of String type all values are _______ by default.

a) null

b) Null

c) 0

d) Nothing

[Link] act of initializing array is also called as _____

a) Populating an array

b) Assigning array

c) Initializing

d) Factoring and array

[Link] is the result of the following statements?

Dim strCities() As String = {"Bombay", "Chennai", "Ladakh", "Tamil Nadu"}


strCities(2)=”Kolkata”

a) Compilation Error

b) Runtime Error

c) strCity array is {“Bombay”, “Ladakh”, “Kolkata”,”Tamil Nadu”}

d) strCity array is {“Bombay”, “Chennai”,”Kolkata”, “Tamil Nadu”}

[Link] is an Array in C language.?

A) A group of elements of same data type.

B) An array contains more than one element

C) Array elements are stored in memory in continuous or contiguous locations.

D) All the above.

[Link] a correct statement about C language arrays.

A) An array address is the address of first element of array itself.

B) An array size must be declared if not initialized immediately.

C) Array size is the sum of sizes of all elements of the array.

D) All the above

[Link] array Index starts with.?

A) -1

B) 0

C) 1

D) 2

[Link] a correct statement about C language arrays.

A) An array size can notchanged once it is created.

B) Array element value can be changed any number of times


C) To access Nth element of an array students, use students[n-1] as the starting
index is 0.

D) All the above

[Link] is the output of C Program.?

int main()

int a[];

a[4] = {1,2,3,4};

printf("%d", a[0]);

A) 1

B) 2

C) 4

D) Compiler error

12. What will be the output of the following C code?

#include <stdio.h>

void main()

int a[2][3] = {1, 2, 3, 4, 5};

int i = 0, j = 0;

for (i = 0; i< 2; i++)

for (j = 0; j < 3; j++)

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

d) Run time error

13. What will be the output of the following C code?

#include <stdio.h>

void main()

int a[2][3] = {1, 2, 3, , 4, 5};

int i = 0, j = 0;

for (i = 0; i< 2; i++)

for (j = 0; j < 3; j++)

printf("%d", a[i][j]);

a) 1 2 3 junk 4 5

b) Compile time error

c) 1 2 3 0 4 5

d) 1 2 3 3 4 5

14. What will be the output of the following C code?

#include <stdio.h>

void f(int a[][3])

a[0][1] = 3;
int i = 0, j = 0;

for (i = 0; i< 2; i++)

for (j = 0; j < 3; j++)

printf("%d", a[i][j]);

void main()

int a[2][3] = {0};

f(a); }

a) 0 3 0 0 0 0

b) Junk 3 junk junkjunkjunk

c) Compile time error

d) All junk values

15. What will be the output of the following C code?

#include <stdio.h>

void f(int a[2][])

a[0][1] = 3;

int i = 0, j = 0;

for (i = 0;i< 2; i++)

for (j = 0;j< 3; j++)

printf("%d", a[i][j]);
}

void main()

int a[2][3] = {0};

f(a);

a) 0 3 0 0 0 0

b) Junk 3 junk junkjunkjunk

c) Compile time error

d) All junk values

16. Comment on the following C statement.

int (*a)[7];

a) An array “a” of pointers

b) A pointer “a” to an array

c) A ragged array

d) None of the mentioned

17. Which of the following is not possible statically in C?

a) Jagged Array

b) Rectangular Array

c) Cuboidal Array

d) Multidimensional Array

18. What is the maximum length of a C String?

a) 32 characters

b) 64 characters
c) 256 characters

d) None of the above

19. How do you accept a Multi Word Input in C Language?

a) SCANF

b) GETS

c) GETC

d) FINDS

20. Choose a correct C Statement about Strings.

a) PRINTF is capable of printing a multi word string

b) PUTS is capable of printing a multi word string

c) GETS is capable of accepting a multi word string from console or command


prompt

d) All the above

21. What is the maximun number of dimensions an array in C may have?

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

23. Array can be considered as set of elements stored in consecutive memory


locations but having __________.

A. Same data type

B. Different data type

C. Same scope

D. None of these

24. Array is an example of _______ type memory allocation.

A. Compile time

B. Run time

C. Both A and B

D. None of the above

25. Size of the array need not be specified, when

A. Initialization is a part of definition

B. It is a formal parameter

C. It is a declaratrion

D. All of the above

26. The information about an array used in program will be stored in

A. Symbol Table

B. Activation Record

C. Dope Vector

D. Both A and B

27. The parameter passing mechanism for an array is


A. call by value

B. call by reference

C. call by value-result

D. None of the above

28. A string that is a formal parameter can be declared

A. An array with empty braces

B. A pointer to character

C. Both A and B

D. None of the above

29. Which of the following function is more appropriate for reading in a multi-
word string?

A. scanf()

B. printf()

C. gets()

D. puts()

30. How will you print on the screen?

A. printf("");

B. printf('');

C. printf("\n");

D. printf(""")

31. Strcat function adds null character

A. Only if there is space

B. Always

C. Depends on the standard


D. epends on the compiler

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()

33. An array elements are always stored in ________ memory locations.?

A. Sequential

B. Random

C. Sequential and Random

D. None of the above

34. What is the output of this program?

void main()

int a[8] = {1,2,3,4,5};

printf("%d", a[5]);

A. 5

B. 6

C. 0

D. Garbage Value

35. What is the output of this program?

void main()
{

int arr[10];

printf("%d %d", arr[-2], arr[11]);

A. 0 0

B. Garbage value 0

C. Garbage value Garbage value

D. Compilation Error

36. What is the output of this program?

#include <stdio.h>

int main()

int arr[5] = {1,2,3,4,5};

int p, q, r;

p = ++arr[1];

q = arr[1]++;

r = arr[p++];

printf("%d, %d, %d", p, q, r);

return 0;

A. 3 4 5

B. 3 4 4

C. 4 3 4
D. 4 4 5

[Link] is correct with respect to size of the datatypes?

a) char > int > float

b) int > char > float

c) char < int < double

d) double > char > int

[Link] of the datatypes have size that is variable?

a) int

b) struct

c) float

d) double

[Link] is ____ datatype in C Programming language.

a) Derived Data type

b) Primitive Data type

c) Custom Data type

d) None of these

40. Comment on the output of this C code?

int main()

int a[5] = {1, 2, 3, 4, 5};

int i;

for (i = 0; i< 5; i++)

if ((char)a[i] == '5')

printf("%d\n", a[i]);
else

printf("FAIL\n");

A. The compiler will flag an error

B. Program will compile and print the output 5

C. Program will compile and print the ASCII value of 5

D. Program will compile and print FAIL for 5 times

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

43. Which of the following is a User-defined data type?

A. typedef int Boolean;

B. typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;

C. struct {char name[10], int age};

D. All of the mentioned


44. What is the size of an int data type?

A. 4 Bytes

B. 8 Bytes

C. Depends on the system/compiler

D. Cannot be determined.

45. What is the output of this C code?

int main()

char chr;

chr = 128;

printf("%d\n", chr);

return 0;

A. 128

B. - 128

C. Depends on the compiler

D. None of the mentioned

46. What is short int in C programming?

A. Basic data type of C

B. Qualifier

C. short is the qualifier and int is the basic datatype

D. All of the mentioned.

47. Comment on the output of this C code?

int main()
{

float f1 = 0.1;

if (f1 == 0.1)

printf("equal\n");

else

printf("not equal\n");

A. equal

B. not equal

C. Output depends on compiler

D. None of the mentioned

48. Comment on the output of this C code?

int main()

float f1 = 0.1;

if (f1 == 0.1f)

printf("equal\n");

else

printf("not equal\n");}

A. equal

B. not equal

C. Output depends on compiler

D. None of the mentioned

49. Which is correct with respect to size of the datatypes?


A. char > int > float

B. int > char > float

C. char < int < double

D. double > char > int

50. What is the output of this C code?

int main()

float x = 'a';

printf("%f", x);

return 0;

A. a

B. run time error

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

Data Flow Diagrams

 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.

Data Flow Diagram Symbols

 DFD symbols are consistent notations that depict a system or a process. It


entails the use of short-text labels, arrows, circles and rectangles to describe
data flow direction. Also forming part of DFDs are varied sub-processes, data
storage points, and data inputs and outputs.

 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.

1. External entities are represented by squares as the source or destination of


data.
2. Processes are represented by rectangles with rounded corners.
3. Data Flows are referred to by arrows to denote the physical or electronic
flow of data.
4. Data Stores are physical or electronic-like XML files denoted by open-ended
rectangles.

Data Flow Diagram

Data Flow Model Diagram


Yourdon and Coad

What modules are

 Modularization is a method to organize large programs in smaller parts, i.e.


the modules. Every module has a well defined interface toward client
modules that specifies how "services" provided by this module are made
available.
 Moreover, every module has an implementation part that hides the code and
any other private implementation detail the clients modules should not care
of.
Layout of the source three. Dotted boxes are files
generated by the compiler, while arrows indicate files
involved in their generation.

Modularization has several benefits, especially on large and complex programs:

 modules can be re-used in several projects;

 changing the implementation details of a module does not require to modify


the clients using them as far as the interface does not change;

 faster re-compilation, as only the modules that have been modified are
actually re-compiled;

 self-documenting, as the interface specifies all that we need to know to use


the module;

 easier debugging, as modules dependencies are clearly specified and every


module can be tested separately.

 Programming by modules using the C language means splitting every source


code into an header file module1.h that specifies how that module talks to the
clients, and a corresponding implementation source file module1.c where all
the code and the details are hidden.
 The header contains only declarations of constants, types, global variables
and function prototypes that client programs are allowed to see and to use.
 Every other private item internal to the module must stay inside the code file
as they are implementation details clients do not need to know. We will now
describe in detail the general structure of the interface and the implementation
files.
Value parameters
 The value parameters copy the actual value of an argument into
the formal parameter of the function. In this case, changes made
to the parameter inside the function have no effect on the
argument.
 This is the default mechanism for passing parameters to a
method. In this mechanism, when a method is called, a new
storage location is created for each value parameter.
 The values of the actual parameters are copied into them. Hence,
the changes made to the parameter inside the method have no
effect on the argument.

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.

What is the Scope of a Variable?

 Before going ahead to learn about local and global


variable scope, let's understand what scope means.
 In simple terms, scope of a variable is its lifetime in the
program.
 This means that the scope of a variable is the block of
code in the entire program where the variable is declared,
used, and can be modified.
 In the next section, you'll learn about local scope of
variables

Local Scope of Variables in C – Nested Blocks


 In this section, you'll learn how local variables work in C. You'll first code a
couple of examples, and then you'll generalize the scoping principle.
▶ Here's the first example:

#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.

 In C, you delimit a block of code by {} . The opening and closing curly


braces indicate the beginning and the end of a block, respectively.
 The main() function has an integer variable my_num that's initialized
to 7 in the outer block.
 There's an inner block that tries to add 10 to the variable my_num.
 Now, compile and run the above program. Here's the output:

Output

my_num is 17

You can see the following:

 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.

 A function can also be referred as a method or a sub-routine or a procedure,


etc.

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){

/* local variable declaration */


int result;

if(num1 > num2)


result = num1;
else
result = 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);

int main (){

/* local variable definition */


int a =100;
int b =200;
int ret;

/* calling a function to get max value */


ret =max(a, b);

printf("Max value is : %d\n",ret );

return0;
}

/* function returning the max between two numbers */


intmax(int num1,int num2){

/* local variable declaration */


int result;

if(num1 > num2)


result = num1;
else
result = num2;

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 −

[Link] Call Type & Description


.

1 Call by value

This method copies the actual value of an argument


into the formal parameter of the function. In this case,
changes made to the parameter inside the function
have no effect on the argument.

2 Call by reference

This method copies the address of an argument into


the formal parameter. Inside the function, the address
is used to access the actual argument used in the call.
This means that changes made to the parameter affect
the argument.

 By default, C uses call by value to pass arguments. In general, it means the


code within a function cannot alter the arguments used to call the function.

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

 In programming, we may require some specific input data to be generated


several numbers of times. Sometimes, it is not enough to only display the data
on the console.

 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.

o Creation of the new file


o Opening an existing file
o Reading from the file
o Writing to the file
o Deleting the file
Functions for file handling

 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:

No. Function Description


1 fopen() opens new or existing file
2 fprintf() write data into the file
3 fscanf() reads data from the file
4 fputc() writes a character into the file
5 fgetc() reads a character from file
6 fclose() closes the file
7 fseek() sets the file pointer to given position
8 fputw() writes an integer to file
9 fgetw() reads an integer from file
10 ftell() returns current position
11 rewind() sets the file pointer to the beginning of the file

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.

The major operations on sequential files are as follows −


 Creating a file − The primary creation of a file is also defined as the loading of
the file. In some implementations, space is first designated to the file, thus the
data are loaded into that Skelton.
 Opening a file − Before a program can access a file for input or output, that file
must be opened. The open operation is given the name of a file and the access
mode (read or write). In Pascal, the procedure reset opens a file in read mode
and the procedure rewrite opens a file in write mode.
 Reading a file − Records are read form a sequential file using the following
types of statements. In COBOL
READ filename INTO identifier
AT END imperative – statement
 where the filename is defined in an FD (File Description), the optional. INTO
clause specifies an identifier in WORKING-STORAGE that will receive the
contents of the record, and the AT END clause is required to specify what is
to happen when the input file is exhausted.
In PASCAL-
read (filename, recordname);
readln (Filename, recordname);

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

[Link] primary tool used in structured design is a:

A. structure chart

B. data-flow diagram

C. program flowchart

D. module

E. None of the above

2.A DFD provides no information about the timing or ordering of processes, or


about whether processes will operate in sequence or in parallel.

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

4. A .... is represented graphically by an arrow into or out of a process

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

[Link] Flow Diagrams are used for :

[A] Process modelling

[B] Modelling interactions in a real time environment

[C] Data modelling


[D] None of these above

[Link] Store Symbol in DFD represents a

A. physical file

B. data structure

C. logical file

D. all of the mentioned

[Link] a context diagram is drawn, which is a simple representation of the


entire system under investigation. This is followed by a level 1 diagram

A) level 0 diagram

B) level 1 diagram

C) level A diagram

D) Both A & B

11. Which of the following can never be sent by call-by-value?

a) Variable

b) Array

c) Structures

d) Both Array and Structures

[Link] file is a sequence of bytes organized into blocks understandable by


the system’s linker?

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

d) Both static variables and Function arguments

[Link] that take input by user before running a program are called?

a) Main function arguments

b) Main arguments

c) Command-Line arguments

d) Parameterized arguments

[Link] is the maximum number of arguments that can be passed in a single


function?

a) 127

b) 253

c) 361

d) No limits in number of arguments

[Link] will be the output of the following C code?

#include <stdio.h>

void m(int *p, int *q)

int temp = *p; *p = *q; *q = temp;

void main()
{

int a = 6, b = 5;

m(&a, &b);

printf("%d %d\n", a, b);

a) 5 6

b) 6 5

c) 5 5

d) 6 6

[Link] will be the output of the following C code?

include <stdio.h>

void m(int *p)

int i = 0;

for(i = 0;i< 5; i++)

printf("%d\t", p[i]);

void main()

int a[5] = {6, 5, 3};

m(&a);

a) 0 0 0 0 0
b) 6 5 3 0 0

c) Run time error

d) 6 5 3 junk junk

[Link] of the following can never be sent by call-by-value?

a) Variable

b) Array

c) Structures

d) Both Array and Structures

19. Which type of variables can have the same name in a different function?

a) Global variables

b) Static variables

c) Function arguments

d) Both static variables and Function arguments

20. Arguments that take input by user before running a program are called?

a) Main function arguments

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

d) No limits in number of arguments


22. What will be the output of the following C code?

#include <stdio.h>

void m(int *p, int *q)

int temp = *p; *p = *q; *q = temp;

void main()

int a = 6, b = 5;

m(&a, &b);

printf("%d %d\n", a, b);

a) 5 6

b) 6 5

c) 5 5

d) 6 6

23. What will be the output of the following C code?

#include <stdio.h>

void m(int *p)

int i = 0;

for(i = 0;i< 5; i++)

printf("%d\t", p[i]);

}
void main()

int a[5] = {6, 5, 3};

m(&a);

a) 0 0 0 0 0

b) 6 5 3 0 0

c) Run time error

d) 6 5 3 junk junk

24. What will be the output of the following C code?

#include <stdio.h>

void m(int p, int q)

int temp = p;

p = q;

q = temp;

void main()

int a = 6, b = 5;

m(a, b);

printf("%d %d\n", a, b);

}
a) 5 6

b) 5 5

c) 6 5

d) 6 6

[Link]

25. Which of the following can never be sent by call-by-value?

a) Variable

b) Array

c) Structures

d) Both Array and Structures

26. Which type of variables can have the same name in a different function?

a) Global variables

b) Static variables

c) Function arguments

d) Both static variables and Function arguments

27. Arguments that take input by user before running a program are called?

a) Main function arguments

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

d) No limits in number of arguments

29. What will be the output of the following C code?

#include <stdio.h>

void m(int *p, int *q)

int temp = *p; *p = *q; *q = temp;

void main()

int a = 6, b = 5;

m(&a, &b);

printf("%d %d\n", a, b);

a) 5 6

b) 6 5

c) 5 5

d) 6 6

30. What will be the output of the following C code?

#include <stdio.h>

void m(int *p)

int i = 0;

for(i = 0;i< 5; i++)


printf("%d\t", p[i]);

void main()

int a[5] = {6, 5, 3};

m(&a);

a) 0 0 0 0 0

b) 6 5 3 0 0

c) Run time error

d) 6 5 3 junk junk

31. What will be the output of the following C code?

#include <stdio.h>

void m(int p, int q)

int temp = p;

p = q;

q = temp;

void main()
{

int a = 6, b = 5;

m(a, b);

printf("%d %d\n", a, b);

a) 5 6

b) 5 5

c) 6 5

d) 6 6

32. What will be the output of the following C code?

#include <stdio.h>

void m(int p, int q)

printf("%d %d\n", p, q);

void main()

int a = 6, b = 5;

m(a);

a) 6

b) 6 5

c) 6 junk value

d) Compile time error


[Link] will be the output of the following C code?

#include <stdio.h>

void m(int p)

printf("%d\n", p);

void main()

int a = 6, b = 5;

m(a, b);

printf("%d %d\n", a, b);

a) 6

b) 6 5

c) 6 junk value

d) Compile time error

[Link] C Program should contain which function.?

A) printf()

B) show()

C) scanf()

D) main()

[Link] is the minimum number of functions to be present in a C Program.?

A) 1

B) 2
C) 3

D) 4

[Link] is the output of C Program with functions.?

static void show();

int main()

printf("ROCKET ");

show();

return 0;

static void show()

printf("STATIC");

A) ROCKET

B) ROCKET STATIC

C) STATIC ROCKET

D) Compiler error

[Link] is the maximum number of statements that can present in a C


function.?

A) 64

B) 128

C) 256

D) None of the above


[Link] characters are allowed in a C function name identifier.?

A) Alphabets, Numbers, %, $, _

B) Alphabets, Numbers, Underscore ( _ )

C) Alphabets, Numbers, dollar $

D) Alphabets, Numbers, %

[Link] do you call STAR * and Ampersand & in a c program context.?

int a=10, *p;

p = &a;

printf("%d %d", a, *p);

A) * = ADDRESS OF operator, & = VALUE AT operator

B)* = ADDRESS OF operator, & = ADDRESS OF operator

C) * = VALUE AT operator, & = ADDRESS OF operator

D) * = VALUE AT operator, & = VALUE AT operator

[Link] passed to a function in C language are called ___ arguments.

A) Formal arguments

B) Actual Arguments

C) Definite Arguments

D) Ideal Arguments

[Link] received by a function in C language are called ___ arguments.

A) Definite arguments

B) Formal arguments

C) Actual arguments

D) Ideal arguments
[Link] a corrects statement about C language function arguments.

A) Number of arguments should be same when sending and receiving

B) Type of each argument should match exactly

C) Order of each argument should be same

D) All the above

[Link] a non Library C function below.

A) printf()

B) scanf()

C) fprintf()

D) printf2()

[Link] do you call this C Function calling itself.?

int funny2()

funny2(num);

A) Indefinite Function

B) Definite Function

C) Cursive Function

D) Recursive Function

[Link] is the scope of a function?

a) Whole source file in which it is defined

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

[Link] is the scope of an external variable?

a) Whole source file in which it is defined

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

[Link] sizes are optional during array declaration by using ______ keyword.

a) auto

b) static

c) extern

d) register

[Link] will be the output of the following C code?

#include <stdio.h>

void main()

int x = 3;

x = 4;

printf("%d", x);

} }

a) 4

b) 3

c) 0
d) Undefined

[Link] will be the output of the following C code?

#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

[Link] correct statement about Functions in C Language.


a) A Function is a group of c statements which can be reused any number of
times

b) Every Function has a return type

c) Every Function may no may not return a value

d) All the above

51.A function which calls itself is called a ___ function.

a) Self Function

b) Auto Function

c) Recursive Function

d) Static Function

[Link] are the types of functions in C Language?

a) Library Functions

b) User Defined Functions

c) Both Library and User Defined

d) None of the above

[Link] correct statements about C Language Pass By Value.

a) Pass By Value copies the variable value in one more memory location

b) Pass By Value does not use Pointers

c) Pass By Value protects your source or original variables from changes in


outside functions or called functions

d) All the above

[Link] received by a function in C language are called ___


arguments.

a) Definite arguments

b) Formal arguments
c) Actual arguments

d) Ideal arguments

[Link] data structure used to implement recursive function calls


_____________

a) Array

b) Linked list

c) Binary tree

d) Stack

[Link] principle of stack is __________

a) First in first out

b) First in last out

c) Last in first out

d) Last in last out

57. In the absence of a exit condition in a recursive function, the


following error is given __________

a) Compile time error

b) Run time error

c) Logical error

d) No error

[Link] one of the following is correct syntax for opening a file.

a) FILE *fopen(const *filename, const char *mode)

b) FILE *fopen(const *filename)

c) FILE *open(const *filename, const char *mode)

d) FILE open(const*filename)
[Link](NULL) flushes all ____________

a) input streams

b) output streams

c) previous contents

d) appended text

60._____removes the named file, so that a subsequent attempt to open it


will fail.

a) remove(const *filename)

b) remove(filename)

c) remove()

d) fclose(filename)

[Link] does tmpfile() returns when it could not create the file?

a) stream and NULL

b) only stream

c) only NULL

d) does not return anything

[Link] is an integer type defined in stdio. hand has a value


____________

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+”

[Link] a function which is used to write a string to a file ______

a) pits()

b) putc()

c) fputs()

d) fgets()

[Link] a function which is used to read a single character from a file at


a time?

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

[Link] in which of the following the character conversion is


possible ______

a) text stream

b) binary stream

c) output stream

d) input stream

[Link] type can be represented by ____________

a) file name

b) file extension

c) file identifier

d) none of the mentioned

70.______ is a unique tag, usually a number identifies the file within the
file system.

a) File identifier

b) File name

c) File type

d) None of the mentioned

[Link] create a file ____________

a) allocate the space in file system


b) make an entry for new file in directory

c) allocate the space in file system & make an entry for new file in
directory

d) none of the mentioned.

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

[Link] is DFD? Types of DFD?

[Link] Recurion with example?

[Link] DFD Symbols?

[Link] Functions? with examples?

[Link] Scope of variables? with examples?

TEN MARKS

[Link] explain about Functions ? and its Declarations and parameters?

[Link] discuss about File ? and its Functionsand operations?

 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.

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

You might also like