0% found this document useful (0 votes)
141 views111 pages

Class 12 Final Notes

Uploaded by

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

Class 12 Final Notes

Uploaded by

Herman Pecassa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 111

1|Page

System Analyst:
System analyst is a key person in system development process who analyses existing system and designs, implements
and evaluates the new system that tries to overcome the limitations of the existing system. In order to perform those
tasks, a system analyst constantly interacts with users and managers within and outside the company. On large
projects, the analyst works as a member of an IT department team.
Attributes/ Characteristics of System Analyst:
1. Knowledge of Organizations: A system analyst must have the knowledge of 'working mechanism',
'management structure' and 'functional relationship among different departments' of an organization for which the
information system is to be developed.

2. Knowledge of-Computer System: A system analyst must have knowledge about recent development in
computer system so that he/ she can advise the core development team to use the latest computer system which
addresses user's need with higher level of efficiency.

3. Good Inter-personal Relation: An analyst must be good listener, a good diplomat and Win users over as
friends. He/ She must be able to resolve conflicting requirements. He/ She must understand people and be able to
influence them to change their minds and attitudes. He/ She must understand their needs and motivate them to
work well under stressful conditions such as meeting deadlines etc.

4. Communication Skills: An analyst is also required to orally present his design to groups of users. He/ She must
thus be able to organize his thoughts and present them in a language that can be easily understood by users. Good
oral presentations and satisfactory replies to questions are essential to convince management about the usefulness
of computer-based information systems

5. Analytical Skill: System analysts are required to find solution of problem. A good analyst must be able to
perceive the core problem and discard duplicate data and information in the problem statement. A good analyst
will use appropriate analytical tools as necessary.

6. Breadth of Knowledge: A system analyst has to work with persons performing various jobs in an organization.
He/She may have to interact with accounts sales persons, Clerical staff, production supervisors, stores officers,
purchases officers, directors, etc. A system analyst must understand how they do their jobs and design systems to
enable them to do their job better.

****
Roles and Responsibilities of System Analyst
The success of an information system development is based on the role of system analyst. Among several roles,
some important roles are described below.
1. Change Agent: The analyst may be viewed as an agent of change. A system is designed to introduce changes
and the way how the user and organization handles information or makes decision. So the system analyst may
use different approaches to introduce changes.

2. Investigator and Monitor: A system analyst should investigate the existing system to find the reasons for its
failure. The role of an investigator is to extract the problems from existing systems. The role of monitor is to
undertake and successfully complete a project. In this role, the analysts must monitor programs in relation to
time, cost and quality.

3. Architect: The analyst’s role as an architect is an interface between the user’s logical design requirements
and the detailed physical system design. As an architect, the analyst also creates a detailed physical design of
system. A system analyst makes the design of the information system architecture on the basis of the end
user's requirements. This design becomes the blueprint for the programmers.
2|Page

4. Psychologist: The system analyst plays the role of psychologist when he/she, reaches the people, interprets
their thoughts and draw conclusion from these interaction. Psychologist plays a major role during the phase of
fact finding.

5. Motivator: The analyst plays the role of motivator in order to make the users accept the new system. The
analyst’s role as a motivator becomes very obvious and essential during the first few weeks after the
implementation of new system to make it familiar with them.

6. Defining and Prioritizing the Requirements: The most important and difficult duty of an analyst is to
understand the user’s requirements. There is a need to set priority among the requirements of various users.
The analyst must convince all the users about the priority of requirements.

7. Analysis and Evaluation: The system analyst analyses the working of the current information system in the
organization and finds out the extent to which they meet user's needs. On the basis of the collected
information, the analyst evaluates and finds the best characteristics of the new system which will meet the
user’s requirements. An analyst must critically evaluate a system after it has been in use for reasonable period
of time. The analyst must decide when to do evaluation, how to do evaluation, and how to collect user’s
comments.

8. Designing System: After specifications are accepted, the analyst designs the system. The design must be
understandable to the system implementer. The design must be flexible to accommodate changes easily. An
analyst must know the latest design also to assist implementer in his task.

Assignment
1. List out the types of information system?
2. Who is system analyst? List out the roles of system analyst.
3. List out the characteristics of system analyst.
*****

System Development Life Cycle (SDLC)


SDLC is a systematic way of developing any new system. It consists of a set of development activities that have a
prescribed order. It is the life span of an information system from its (beginning) initiation until it is removed or
redesigned. The term ”development cycle” is used to acknowledge the importance of recycling in meeting
information needs. The systems development life cycle is classically thought of as the set of activities that
analysts, designers and users carry out to develop and implement an information system. It creates the
framework carefully for structuring, planning and control the process of developing an information system
which fulfils the demands of information needs. It is a part of software engineering. IEEE defines SDLC as “the
period that starts when the product is conceived and ends when the software is no longer available for use".

Importance and Necessity of SDLC


System is defined as an aggregation or assemblage of objects / entities of the real World environment joined in
same regular interaction or interdependence. There are various types of systems in the real world environment
varying from simple grocery store to record keeping of statistical sites. Besides, many trends in the
development of industry and commerce have made computer-based systems essential to efficiently run
organizations. Similarly, every organization, governments and non-government agencies use computer based
system for efficient processing and running. The designing of system using SDLC is necessary due to following
reasons.
a. The size of the organizations is becoming larger due to rapid rate of industrial development.
b. Computer-based processing enables the same data to be processed in many ways, based on needs.
c. As the volume of data has increased and the variety of information and their timeliness is now of great
importance.
3|Page

d. Organizations are distributed with many branches.

System Development Model


1. The Waterfall Model:
This model is some time called classic life cycle because it suggests a systematic, sequential
approach to software development that begins with customer specification of requirements and progress through
planning, modeling, construction, etc. It is a oldest type of model for software engineering. This takes the
fundamental process activities of specification, development, validation and evolution and represents them as
separate process phases such as requirements Specification, software design, implementation, testing and so on.

Requirements Analysis and Definition: It is the first stage of waterfall model. In this stage, the developer should
identify the actual requirements of the given problem. After that, the problems are analyzed and prioritized as per the
requirements of the problem. Finally these requirements are stated as problem statement.

System Design: In this stage the systems design process partition the requirements to either hardware or software
systems. It establishes overall system architecture. System design involves identifying and describing the fundamental
software system abstractions and their relationships.

Implementation and Unit Testing: During this stage, the system design is realized as a set of programs or program
unit testing involves verifying that each unit meets its specification.

Integration and System Testing: The individual program units or programs are integrated and tested as a complete
system to ensure that the software requirements have been met. After testing, the software system is delivered to the
customer.

Operation and Maintenance: In this stage, the system is installed to the desire location. The maintenance involves
correcting errors which were not discovered in earlier stages of the life cycle, improving the implementation of system
units and enhancing the system’s service as new requirements are discovered.

Advantages:
-It is simple model suitable for small size project.
-It is less expensive.
- Model required fulfillment of one phase unless it will not allow to go to next phase.
- All the testing and modification is done is the same phase, chances of defect multiplication reduced.
- When new team member joins, referenced documents help them to understand the project.
- The project with short span time can be developed with this model in better quality.
4|Page

Disadvantages:
-It has no back track mechanism.
- It is not suitable for large size project.
- It has lack of proper documentation.
- Takes lot of time to change and update the project documents.
- This model doesn’t suitable for randomly changing requirement.
2. Prototyping Model:
Prototyping is the iterative process of system development which is more appropriate for
developing new system where there is no clear idea of requirements, inputs and outputs. Using prototyping,
programmers can build early versions of systems. These systems are then continuously modified until the user is
satisfied. Prototyping is especially helpful in situations where there will be heavy user interaction with the system,
where the needed output is uncertain, and in some decision support applications where the logic is hard to determine
in advance. The developer interviews the user and designs an initial system using a database management system. The
user works with the prototype and suggests changes. This process repeats until the user or developer is satisfied.
Development of Prototype
The figure shows the steps involved in developing a type of prototype. There are 4 steps
and are as follows:
1. Identify the user needs: The system analyst interviews the user to obtain an idea of
what is required from the system.
2. Develop a prototype: The system analyst, working with other information specialists,
uses one or more prototyping tools to develop a prototype.
3. Determine if prototype is acceptable: The analyst educates the user in prototype use
and provides an opportunity from becoming familiar with the system. The user advises the
analyst whether the prototype is satisfactory. If so, then the next step, that is step 4 is
taken, else the prototype is revised by repeating steps 1, 2 and 3 with a better
understanding of the user needs.
4. Use the prototype: The prototype becomes the operational system. This approach is possible only when the
prototyping tools enable the prototype to contain all the essential elements of the new system.
Advantages:
- Communications between the systems analyst and user are improved.
- The expert can do a better job of determining the user's needs. The user plays a more active role in system
development.
- The expert and the user spend less time and effort in developing the system.
- Implementation is much easier because the user knows what to expect.
- A system is developed through operational prototyping is capable of easy adaptation.
Disadvantages:
- Because of the iterative nature of prototyping, there is no definite deliverable or completion deadline.
- Code inefficiencies may be a drawback in terms of functionality
- The computer-human interface provided by certain prototyping tools may not reflect good design techniques.

3. Spiral Model
In this model, process is represented as a spiral rather than as a
sequence of activities with backtracking. Each loop in the spiral
represents a phase in the process. It has no fixed phases such as
specification or design loops in the spiral are chosen depending on
what is required. Risks are explicitly assessed and resolved throughout
the process. Each loop in the spiral represents a phase of the software
process. Thus, the innermost loop might be concerned with system
5|Page

feasibility, the next loop with system requirement definition and analysis, the next loop with system design and so
on.
1. Planning: The project is reviewed and a decision made whether to continue with a further loop of the spiral. If it is
decided to continue, plans are drawn up for the next phase of the project.
2. Risk Analysis: For each of the identified project risks, a detailed analysis is carried out. Steps are taken to reduce
the risk. For example, if there is a risk that the requirements are inappropriate, a prototype system may be
developed.

3. Software Development: After risk evaluation, a development model for the system is chosen. For example, if user
interface risks are dominant, an appropriate development model might be evolutionary prototyping. If safety risks
are the main consideration, development based on formal transformations may be the most appropriate and so on.
The waterfall model may be the most appropriate development model if the main identified risk is sub-system
integration e project are defined by the
4. User Evaluation: Specific Objectives for the phase of the project are identified by the evaluation of users.
Constraints on the process and the product are identified. And detailed management plan is drawn up.

Advantages:

• High amount of risk analysis hence, avoidance of Risk is enhanced.


• Good for large and mission-critical projects.
• Strong approval and documentation control.
• Additional Functionality can be added at a later date.
• Software is produced early in the software life cycle.
• Project estimates in terms of schedule, cost etc become more and more realistic as the project moves forward
and loops in spiral get completed.
• It is suitable for high risk projects, where business needs may be unstable.
A highly customized product can be developed using this.

Disadvantages:

• Can be a costly model to use.


• Risk analysis requires highly specific expertise.
• Project’s success is highly dependent on the risk analysis phase.
• Doesn’t work well for smaller projects.
• It is not suitable for low risk projects.
• May be hard to define objective, verifiable milestones.
• Spiral may continue indefinitely.
6|Page

System Development Phase


Various models of system development have various stages built in general the most common phase of SDLC are as
below.

1. System Study:
A system is intended to meet the needs of an
organization. Thus the first step in the design is to specify
these needs or requirements. The top manager of the
organization takes the basic decision to use a computer
based (information) system for managing the
organization. The management of organization consults
with system analyst. For instance his / her role is similar
to the house architect for building a house. The first job
of the system analyst is to understand the existing
system that could be manual or computer based. During
this stage he/ she understand the organization by means
of extensive discussions with all levels in the organization
hierarchy, namely, top managers to clerks. Based on this he/ she identifies what priority assigns. During this
phase, the objectives of system are identified. It is predetermined course of action. This involves forecasting
because in order to plan the future course of action, it is essential to anticipate the future. Because problem
definition deals with the future, uncertainty is present. In summary, system study studies the
following questions:
- What is to be done in future.
- How to do it.
- When to do it.
- Who is to do it.
2. System Analysis:
”Systems analysis is the dissection of a system into its component pieces to study how those component
pieces interact and work”. Systems analysis is a term that collectively describes the early phases of systems
development. System analysis is defined as those phases and activities that focus on the business problem,
independent of technology (for the most part). Specifically, we refine our definition of systems analysis as
follows. "Systems analysis is (1) the survey and planning of the system and project, (2) the study and analysis
of the existing business and information system, and (3) the definition of business requirements and
priorities for a new or improved system.
3. Feasibility Study:
7|Page

Feasibility study is the most important activity in the system analysis phase. It analyses the proposed system
from different aspects so that it makes us clear that how practical or beneficial the system will be to the
organization. So it tells us whether the system is feasible to design or not. It is defined as the pre-defined
activity in SDLC that determines existence of various scopes for the development of new system. It
determines the future prospective about the new system. In feasibility study, we focus on the long term gain
instead of short term benefits. It deals with economical aspect, technical aspect, operational aspect,
behavioral aspect, schedule aspect, legal aspect etc. about the system. Moreover it also discuss about the
inputs, outputs and the efficient processing mechanism for the software. If the project is not feasible from
any aspect then the system will not give the maximum benefits for the users.

Types of Feasibility Study:


a. Economical Feasibility: It concerns with cost effectiveness of the system. The main objective of
economical feasibility is to calculate approximate cost-both the development cost and the operational cost
and the benefits from the system. Management always thinks that the short term cost is overshadowed by
the long term gain. Both direct and indirect benefits should be measured. Developers always develop
suitable system for an organization that should be economically feasible. So it is popularly known as cost
benefit analysis.
b. Technical Feasibility: It concerns with the availability of the hardware, software and the support
equipments for the complete development of the system. It also deals with the other different types of
technical requirements: uninterrupted power supply, network and internet connection, etc. Moreover it
also deals with the technical manpower to develop and operate the system.
c. Operational Feasibility: It concerns with smooth operation of the system. It is all about the problems that
may occur during operation of the system after its development. For the smooth operation of the system,
there are different factors such as: accuracy, response time, security, services and the efficiency of the
system. Most of the clients want user friendly and reliable systems which are the key factors for the smooth
operation.
d. Behavior Feasibility: It concerns with behavior of the users and the society towards the new system /
technology. Generally, most of the traditional employees are not easily ready to upgrade them with the new
system/ technology. They may feel that their jobs are unsecured because of new system and react
accordingly. The behavior feasibility is the key factor for the effective operation of the system.
e. Schedule feasibility: It is the process of splitting project into tasks and estimate time and resources
required to complete each task. It determines the deadline to complete a system and schedule the task
accordingly. If the system is completed in the given deadline then it is called good system design otherwise it
affects other feasibility such as economical, technical, operational etc.
f. Legal Feasibility: It concerns with legal issue of the system. If the system is illegal then the system
designing is meaningless. Everything is measured whether it is legal or illegal. It considers copyright law,
labor law, foreign trade, tax etc. It plays role in the contract between the clients and the developer and also
considers the code ownership of the system.
Assignment
1. List out the phases of SDLC with figure.
2. List out the types of feasibility study.

4. System Design:
The next step is to develop the logical design of the system. During this phase, the logic of the system is
designed. The system design should begin from the objectives of the system, namely, the information
requirement of users, and use this to find the necessary database. After complete this phase, the overall
8|Page

logical solution of a problem is determined. During system design different tools are used such as Flow
Chart, Algorithm, DFD (Data Flow Diagram, ERD (Entity Relationship Diagram) etc. Some methodologies
drawn this phase are given below. Type of system design methodologies
a, Top Down Methodology .
b, Bottom Up Methodology.

5. System Development:
After designing a logical diagram of a system then next step is to convert into program. This process is called
system development. Flowchart, algorithm, pseudo code etc. are the outlines the procedures for taking the
input data and processing it into usable output. We are now ready to code the instructions that will control
the All programming languages, C, C++, JAVA, FORTRAN, COBOL, BASIC and so on, are composed of
instructions that enable the computer to process a particular application, or perform a particular function.
In system development following processes are done.
- Convert logical structure in to programs in programming language.
- Database is created. 0 User Operational documents are written.
- Users are trained. - The internal documentation of a system are prepared.
6. System Testing:
System Testing System testing is an investigation conducted to provide stakeholders with information about
the quality of the product or service under test. System testing also provides an objective, independent view
of the software to allow the business to appreciate and understand the risks of software implementation.
Test techniques include, but are not limited to, the process of executing a program or application with the
intent of finding software bugs.
System testing can also be stated as the process of validating and verifying that a software program/
application/ product:
- System meets the business and technical requirements that guided its design and development.
- System works as expected. a System can be implemented with the same characteristics.

Some testing methods are given below.


a, White Box Testing: White box testing of software is predicted on close examination of procedural details.
Logical path through the software and collaborations between components are tested by providing test case
that exercise specific sets of conditions or loops. White box testing is used when the tester has access to the
internal data structures and algorithms including the code that implement these. It is also called glass box
testing.
b. Black Box Testing: Black box testing treats the software as a "black box" -without any knowledge of
internal implementation. Black box testing methods include: equivalence partitioning, boundary value
analysis, specification-based testing etc. It is also called functional testing because it tests whether a system
is functioning or not. In this testing, the tests are derived from program or component specification.

7. Implementation:
Implementation involves testing the installed system, converting from the old system to the new one and
training the users. This phase consists of implementation of the system into a production environment, and
resolution of the problem identified in testing phase. The new system is installed and operated with old
system until it has been checked out. Then the old system is then removed from operation and new system
takes from thereafter.

8. Maintenance and Review:


When the system is implemented, maintenance and modification begin. Like any system, there is an ageing
process that requires periodic maintenance of hardware and software. If the new system is inconsistent
(contradict) with the design specification, then changes have to be made. The software and hardware also
9|Page

requires periodic ‘maintenance so as to keep in tune with design specification and to innovate new ideas
into the system. The content of the review will include:
- Objectives met - Cost - Performance - Standards - Recommendation
Types of Maintenance
1. Corrective Maintenance: It corrects the run time errors during the Operation.
2. Adaptive Maintenance: It modifies or adds new features in the system according to the environmental
change.
3. Perfective Maintenance: It makes the system perfect, up-to-date and improve the life of the system. In
this way software development stages goes on towards the fulfillments of new requirements of users.
Finally the system development project is reviewed in order to verify the customer requirements,
performance evaluation, and time and coast evacuation. It is important for redesign and modification in
next versions of the system in upcoming life cycle.

Assignment
1. Differentiate between black box and white box testing.
4. List out different system implementation method.
5. List out different types of system maintenance.
Documentation
Documentation is not a separate stage, it requires throughout the stages in the development process. It
consists of the written description and procedures about the software. It consists of the detail description about
software requirements specification, feasibility report, software designing report, description about input/output
and processing mechanism, source code, comments, manuals, guides and effective help desk. Moreover the
documentation should describe everything you have done so far. It consist the limitations of the software; demo to
describe how to run the software and the minimum requirements in order to run it smoothly. The following points
describe the actual importance of documentation.
- Effective and easy use for the users.
- It is easy to remember the program logic and instruction for the programmer during programming.
- It helps to solve the best way solution.
- For the future reference to maintenance and modify.

Why documentation needed?


Documentation is needed because of the following reasons.
- It is a means for transfer of knowledge and details about description of the system.
- To help corporate audits and other requirements of the organization.
- Needed for IT infrastructure management and maintenance.
- Needed for migration to a new software platform.

Mainly documentation is categorized into two types: internal documentation and external documentation.

Internal Documentation: It is used by the system analyst and the programmer during development process. It is
very useful for the development period and also useful in future for the modification and maintenance of the
software. Examples of internal documents.
10 | P a g e

- SR5 (System Requirements Specification) report contents the detail description about the actual requirements
and the feasibility description about the total benefits for the organization with effective solution of right
problem.
- Software design report consists of logical as well as physical design report. It consists the different tools and
techniques used to solve the problems.
- Source code and Comments of the software itself a part of documents for the programmer and comments are
also used in programs. It also includes documentation for testing and verification and maintenance.

External Documentation: It is used by the user during the running time of the .software. It includes the detail
description in terms of manuals, guide and help files. It mainly deals with how to effective use of software

Assignment
1 List the importance of documentation. .
2. List the types of documentation.

Short notes:
Data Flow Diagram (DFD):
A pictorial representation of any business activity will be more effective than a narrative one. It is easier to
understand or grasp when being explained and most important of all, it is much more precise and less ambiguous
than a narrative one. During the course of analysis, the System Analyst (SA) has to gather enough information in
order to answer the following questions. It also serves as a form of checklist:
• What are the processes that make up a system?
• What data is used in each of the processes?
• What and how is the data stored?
• What data enters and leaves the system?
All the information gathered has to be recorded. For this purpose, the SA will normally use the DFD. A DFD is a
diagrammatic representation of the flow of data through a process / system or sub-system/sub-process. It shows
what happens to the data as it goes through a process. Like a flowchart, a DFD also uses standard symbols and
notations.

Entity Relationship Diagram (ERD)


The diagrammatic representation of entities attributes and the described by E-R diagram. The E-R diagram is
an overall logical structure of a database that can be expressed graphically. It was developed to facilitated database
design and the simplicity and pictorial clarity of this diagramming technique have done great help in the designing
part of database. The basic components of ER diagram are given below.
1. Entity: An entity is a " thing” or "object” in the real word that is distinguishable from other objects. For example
each person is an entity. An entity has a set of properties and the Student values for some set of properties may
uniquely identify an entity. For example, if student is an entity, is identified by registration number. It is represented
by rectangle.
2. Attribute: Attributes are properties possessed by on entity or relationship. For example stu_no, stu_narne
stu_sub are the attributes of the entity student. Attribute is represented by oval.
11 | P a g e

3. Relationship: A relationship is an association among several entities and represents meaningful dependencies
between them. For example the association between teachers and students is teaching. It is represented by
diamond.
4. Lines: The flow of information is indicated by the lines in ER-diagram. It is simply a line. It is a connector of
entities, attributes and relationship

Case Tools:
Computer aided Software engineering tool is automatic computer based program that helps for software
engineering and SDLC process. It is very fast and effective tools for the development of big scale software. It helps in
analysis, design, implementation, testing and maintenance. Moreover it also helps in business planning, project
management, user interface designing, database designing, programming and documentation. Now visual CASE is
very popular which provides different facilities such as code generation, code conversion drag and dropped features
etc. Oracle 2000 Designer, TOAD, Visual CASE, Rational Rose and Cold Fusion are the some of the popular visual case
tool.

Unified Modeling Language (UML) :


UML is a standardized general-purpose modeling language in the field of object-oriented software engineering. The
standard is managed, and was created by, the Object Management Group. UML includes a set of graphic notation
techniques to create visual models of object-oriented software. It is used to specify, visualize, modify, construct and
document the artifacts' of an object-oriented software-intensive system under development. UML offers a standard
way to visualize a system's architectural blueprints, including elements such as: activities, actors, business processes,
database schemas, etc. Various notions are used to construct the objects and their activities in the problem domain
such as use case diagram, object diagram, class diagram, activity diagram etc.

Chapter -2
Concept of Database.
Data:
Data is raw facts which are composed of alphabets, digits and other symbols. It may or may not give any sense.
For example: 1, Rubina, 5.4, 2,_Ram etc.
Information:
When data are processed using a database program or software, they are converted to the meaningful result,
called information. In other words, the output of data processing is called information. It is an organized collection
of related data, which gives a complete sense. Example: Information about weight of 3 students.
Height of students

SN Name Height (Feet. Inch)

1 Rubina 5.6

Database: 2 Kamal 5.2


Database is a collection of interrelated data of objects or
entities stored in tabular form. 3 Rajan 4.2 Database gives very useful
information for an organization during data manipulation and
decision making. It provides a base or foundation for managing large volume of data in well organized manner, For
example: Phone Diary, Result Sheet, Customer Records and Price List etc.

Database Management System (DBMS) :


12 | P a g e

A database management system is computerized records keeping system. It is a software that defines, manipulates
and manages the database. It allows accessing the files, updating the records and retrieving data as requested. In
other words, DBMS is defined as the collection of interrelated data and set of programs to access those data. The
primary goal of a DBMS is to provide an efficient and effective environment for both data retrieval and storing data
in database. Commercially database management system is called database packages or also called database engine.
Some examples are FoxPro, DBase, Sybase, MS Access, My SQL, MS SQL Server, Oracle and DB2 etc.

The above figure shows the logical structure of database management system. User may be persons or
application from external environment that supplies various requests to the system. Database requests mean
the various activities from users. The database system checks for the requests and performs various
activities as per the need of users. Some major database activities are:
• Adding new file to the database
• Inserting data into the database file
• Retrieving / Viewing data from the database
• Updating data in existing database file
• Deleting data from the database file
• Removing files from the database

Advantage of DBMS:
• Sharing data: Data stored in a database can be shared. It refers to the capacity that makes data
simultaneously accessible by many users without any interference.
• Reduced data redundancy: The same data may be duplicated at many times or i , places, is called data
redundancy, DBMS reduces such type of duplication of data from database.
• Data backup and recovery: DBMS provides backup facilities to store data for future use. If any files or data
lost in any computer, it is possible to restore them from database server.
• Inconsistency avoided: When the same data is duplicated and changes are made at one site, and not on
other sites, it causes data inconsistency. DBMS avoided such type of data inconsistency. 0 Data integrity:
Data integrity means data accuracy, consistency and up to date. A DBMS should provide capabilities for
defining and enforcing constraints for data integrity.
• Data security: In database system, an unauthorized person cannot access data from database. Although
various departments may share data in database, access to specific information that can be limited to
selected users.
• Data independence: Description of the data (Schema) is stored in one central place. Therefore, applications
do not have to recompile when the format of the data changes.
• Multiple user interfaces: DBMS provides variety of interfaces for various users. It provides query language
interface, forms and command interfaces so that users interact easily with the database.
• Process complex query: It provides different methods such as View, trigger, index etc. to process complex
queries.

Disadvantage of DBMS:
13 | P a g e

• Expensive: Database software is very expensive for large computer systems. It also requires overhead costs
for maintaining and integrity functions.
• Changing technology: It is fast changing technology.
• Needs Technical Training: It is complex to understand and implement. So, proper training is required for
staff to work properly in the database system.
• Backup is needed: It needs to explicit back up. This adds costs as new storage space are needed to hold the
data.
• It is bit complex: Since it supports multiple functionality to give the user the best, the underlying
software has become complex. The designers and developers should have thorough knowledge about
the software to get the most out of it.
• More memory is needed: Because of its complexity and functionality, it uses large amount of
memory. It also needs large memory to run efficiently.
• DBMS system works on the centralized system, i.e.; all the users from all over the world access this
database. Hence any failure of the DBMS, will impact all the users.
• DBMS is generalized software, i.e.; it is written work on the entire systems rather specific one.
Hence some of the application will run slow.

Objectives of DBMS:
• It allows the growth of database system.
• DBMS provides safety mechanism for database.
• It allows multiple users to be active at one time.
• It eliminates redundant (duplicate) data.
• In DBMS, making the latest modification to the database available immediately.
• It provides storage area for mass amount of relevant data.

Database Model:
There are different forms of database management system, each characterized by the way where data are defined
and structured, called database model. It is the organizing principles of records in secondary storage. Following are
the different architectures:
• Hierarchical Database Model
• Network Database Model
• Relational Database Model
• Entity Relational Database Model

1. Hierarchical Database Model


Hierarchical database model is one of the oldest type database models. In this model data is represented in the
form of records. Each record has multiple fields/ attributes. All records are arranged in database as tree like
structure. The relationship between the records is called parent child relationship in which any child record
relates to only a single parent type record. In the figure below, there are parent records at the top level with
high privileges and child records at bottom level. There are three types of records: students, management and
department chief records.
14 | P a g e

Advantages
• It is the easiest model. o It has one or more attributes.
• The searching is fast and easy, if parent is known.
• It supports one-to-one and one-to-many relationship.
Disadvantages:
• It is old fashioned, outdated database model.
• It does not support many-to-many relationship.
• The dependency on parent node is not beneficial always.
• It increases redundancy because same data is to be repeated in different places.

Assignment
1. Lists the advantages and disadvantages of DBMS.
2. Draw a figure to show example of hierarchical database model.

2. Network Database Model


The network database model replaced hierarchical database m0d€1 due to some limitations on the model.
Suppose if an employee relates to two departments, then the hierarchical database model cannot able to
arrange records in proper place. So network database model was emerged to arranged non-hierarchical
database. The structure of database is more like graph rather than tree structure. A network database model
consists of collection of records which are inter-related to each other with the help of relationship. Each record
has multiple fields and each field has only one data value. In figure below, exam records relate to management
and students, and similarly employee records relate to department chief as well as management. In this model,
each record in the database can have multiple parents that is the relationships among data elements can have
many to many relationships.
15 | P a g e

Advantages:
• It accepts many-to-many relationship, so it is more flexible.
• The searching is faster because of multidirectional pointers.
• The network model is simple and easy to design.
• It reduces redundancy because data shouldn’t be repeated if same data is needed.
Disadvantages:
• It is difficult to handle the relationship in complex programs.
• There is less security because of sharing data.
• It increases the processing overhead due to the complex relationship.

3. Relational Database Model


Relational Database Model In relational database model, the data is organized into tables which contain multiple
rows and columns. These tables are called relations. A row in a table represents a relationship among a set of
values. Since a table is a collection of such relationships, i1 is generally referred to the mathematical term
relation, from which the relational database model derives its name. It is also known as RDBMS Examples of
RDBMS are Oracle, SQL, MS-Access, MySql etc.

Advantages:
• The breaking of complex database table into simple database table becomes possible.
• Database processing is faster than other model.
• There is very less redundancy (repetition of data).
• The integrity rules can easily be implemented.
Disadvantages:
• It is more complex than other models.
• There are too many rules because of complex relationships.
16 | P a g e

• It needs more powerful computers and data storage devices.

4. Entity Relational Database Model


Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among them.
While formulating real-world scenario into the database model, the ER Model creates entity set, relationship
set, general attributes and constraints. ER Model is best used for the conceptual design of a database.ER Model
is based on −

• Entities and their attributes.


• Relationships among entities.

These concepts are explained below.

• Entity − An entity in an ER Model is a real-world entity having properties called attributes. Every attribute is
defined by its set of values called domain. For example, in a school database, a student is considered as an
entity. Student has various attributes like name, age, class, etc.
• Relationship − The logical association among entities is called relationship. Relationships are mapped with
entities in various ways. Mapping cardinalities define the number of association between two entities.

Types of relationship:

• one to one
• one to many
• many to many

One-to-one: Each record in table A must have only one matching record in table B and record in table B must have
only one matching record in table A.

One-to-many: Each record in table A can have multiple matching records in table B and each record in
table B must have only one matching record in table A.
17 | P a g e

Many-to-many: Each record in table A can have multiple matching records in table B and each record in table B can
have multiple matching records in table A. This type of relationship is only possible by defining a third table which
consists of common fields or keys.

Concept of Normalization
Database Normalization is a technique of organizing the data in the database. Normalization is a systematic
approach of decomposing tables to eliminate data redundancy and undesirable characteristics like Insertion,
Update and Deletion Anomalies. It is a multi-step process that puts data into tabular form by removing
duplicated data from the relation tables.

Normalization is used for mainly two purposes:

• Eliminating redundant (useless) data.


• Ensuring data dependencies make sense i.e. data is logically stored.

Normalization rule are divided into following normal form.

1. First Normal Form (1NF)


2. Second Normal Form (2NF)
3. Third Normal Form (3NF)
4. Boyce and Codd Normal Form (BCNF)

1. 1NF
As per First Normal Form, no two Rows of data must contain repeating group of information i.e each set of
column must have a unique value, such that multiple columns cannot be used to fetch the same row. Each
table should be organized into rows, and each row should have a primary key that distinguishes it as unique.
18 | P a g e

The Primary key is usually a single column, but sometimes more than one column can be combined to create
a single primary key. For example consider a table which is not in First normal form

Student Table :
Student Age Subject
Raju 15 Biology, Maths
Suman 14 Maths
Kamal 17 Maths
In First Normal Form, any row must not have a column in which more than one value is saved, like separated
with commas. Rather than that, we must separate such data into multiple rows.

Student Table following 1NF will be :


Student Age Subject
Raju 15 Biology
Raju 15 Maths
Suman 14 Maths
Kamal 17 Maths

Using the First Normal Form, data redundancy increases, as there will be many columns with same data in
multiple rows but each row as a whole will be unique.

2. 2NF
As per the Second Normal Form there must not be any partial dependency of any column on primary key. It
means that for a table that has concatenated primary key, each column in the table that is not part of the
primary key must depend upon the entire concatenated key for its existence. If any column depends only on
one part of the concatenated key, then the table fails Second normal form.
In example of First Normal Form there are two rows for Raju, to include multiple subjects that he has opted
for. While this is searchable, and follows First normal form, it is an inefficient use of space. Also in the above
Table in First Normal Form, while the candidate key is {Student, Subject}, Age of Student only depends on
Student column, which is incorrect as per Second Normal Form. To achieve second normal form, it would be
helpful to split out the subjects into an independent table, and match them up using the student names as
foreign keys.

New Student Table following 2NF will be :


Student Age
Raju 15
Suman 14
Kamal 17
In Student Table the candidate key will be Student column, because all other column i.e Age is dependent on
it.

Student Subject
Raju Biology
19 | P a g e

New Subject Table introduced for 2NF will be : Raju Maths


Suman Maths
Kamal Maths

In Subject Table the candidate key will be {Student, Subject} column. Now, both the above tables qualifies
for Second Normal Form and will never suffer from Update Anomalies. Although there are a few complex
cases in which table in Second Normal Form suffers Update Anomalies, and to handle those scenarios Third
Normal Form is there.

3. 3NF
4. Third Normal form applies that every non-prime attribute of table must be dependent on primary key, or we
can say that, there should not be the case that a non-prime attribute is determined by another non-prime
attribute. So this transitive functional dependency should be removed from the table and also the table must
be in Second Normal form. For example, consider a table with following fields.

Student_Detail Table :
Student_id Student_name DOB Street city State Zip
In this table Student_id is Primary key, but street, city and state depends upon Zip. The dependency between
zip and other fields is called transitive dependency. Hence to apply 3NF, we need to move the street, city
and state to new table, with Zip as primary key.

New Student_Detail Table :


Student_id Student_name DOB Zip

Zip Street city state


Address Table :
**********************************************************************************

Primary Key : A primary key is a special relational database table column (or combination of columns) designated
to uniquely identify all table records.
A primary key’s main features are:
• It must contain a unique value for each row of data.
• It cannot contain null values.
A primary key is either an existing table column or a column that is specifically generated by the database according
to a defined sequence.

Foreign Key: A foreign key is a column or group of columns in a relational database table that provides a
link between data in two tables. It acts as a cross-reference between tables because it references the primary
key of another table, thereby establishing a link between them.
The majority of tables in a relational database system adhere to the foreign key concept. In complex
databases and data warehouses, data in a domain must be added across multiple tables, thus maintaining a
relationship between them. The concept of referential integrity is derived from foreign key theory.
Foreign keys and their implementation are more complex than primary keys.

Composite Key: A composite key, in the context of relational databases, is a combination of two or more columns
in a table that can be used to uniquely identify each row in the table. Uniqueness is only guaranteed when the
columns are combined; when taken individually the columns do not guarantee uniqueness.
20 | P a g e

Database Architecture:
The database architecture describes the organization of all database objects and how they work together. It
affects integrity, reliability and performance. The database architecture involves anything that defines the nature of
the data, data, or how the data flows.
• Centralized Database:
Centralized Database Centralized database is simple
type which works on a client-server basis. It is
located on a particular (central) location and
peripherals are connected with it to storing and
retrieving data as requirement. Centralized
database system run on a single computer system.
A computer system may be single user or multi-
user. It is only suitable for small organization and
small-scale operation. The database is centralized,
so there is no chance of data modification. Hence,
security is not so crucial part here. The
maintenance of database is easier because of data
or records are centrally stored. Since data is out
from access of unauthorized persons, so risk factors
are also minimized
Advantages:
- Cost minimizes.
- High data security.
- No duplication of data.
Disadvantages:
- Data traffic is high.
- Failure of server makes whole system down.
- it is suitable only for small organization.

• Distributed Database/Decentralized Database:


Distributed database is a complex type of database system. It is a collection of multiple logically interrelated
databases which are distributed in much
geographical locations. Data communication is
difficult because they should communicate
through different system to different platforms.
The problem is security control. It also needs more
computer resources. It is much suitable for such
types of organizations, which are distributed all
over the geographical area with similar objectives
and similar data sets. In other words, it is the
collection of different centralized database
systems in different locations.
Advantages:
- Local control over data.
- Fast response for certain queries.
- Lower communication cost.
Disadvantages:
21 | P a g e

- Duplication rate of data is high.


- --
- --
- --
Difference between centralized and distributed database system.
Centralized Database System. Decentralized Database System.

It is simple type database system. It is complex type of database system.

it is located in particular location . It is located in many geographical locations.

It consists of only one database or server. It contains servers or database in several locations.

It is only suitable for small organization. It is suitable for large organization.

Less chance of data lost More chance of data theft and data lost.

Maintenance is easy and high security. Maintenance is complex and low security as compare to
centralized database system.

Failure of server makes the whole system down. Failure of one server does not make the whole system
down.

There is no feature of load balancing. There is feature of load balancing.

Data traffic rate is very high. Data traffic rate is low.

Cost of centralized database system is low. Cost of distributed system is very high.

Data Security:
Data security is protection of data in database system against unauthorized access, modification, failure, losses or
destruction. The authorized access means only right people can get the right access to the right data. There are
different causes of database physical destruction such as fire, water, heat, dust, power failure, theft etc. It might be
accidental loss or physical damage in computer system. In order to protect from such damages database is stored in
different location in different disk (RAID: Redundant Array of Independent Disk). Different types of data recovery
and data locking techniques are used for the security. Some of the data security methods are:
• Using proper backup in disks, tapes, CD etc. provides the security of data from the accidental loss.
• Making physical prevention by using stabilizer and UPS to supply a regular power through which we can
prevent hardware and software from high electricity voltage and irregular power supply.
• Using strong password protection system, making log in the system to prevent data from unauthorized
access to the database.
• By keeping the system under lock or safe place.

Database Administrator (DBA)


DBA is the most responsible person in an organization with sound knowledge of DBMS. He/ She is the overall
administrator of the system. He/ She has the maximum amount of privileges (permission to access database) for
accessing database, settings up system and defining the role of the employees which use the system. The main goal
of the DBA is to keep the database server up-to-date, secure and provides information to users on demand.
22 | P a g e

Qualities of a good DBA .


• S/he must have sound knowledge about database systems: database design, normalizations process, SQL
commands, form and database report.
• S/ he should have depth knowledge of OS in which database server is running.
• S/ he should have sound knowledge of good database design.
• S/he should have sound understanding of network architecture.
• S/ he should have good knowledge of database server.
• S/he must be familiar with modern database packages: MS-Access, MS SQL Server, My SQL, Sybase, Oracle
etc.

Responsibilities of DBA:
• DBA defines data security, data integrity, schemas, forms, reports, relationships and user privileges.
• DBA has responsibility to install, monitor and upgrade database server.
• S/he provides different facilities for data retrieving and making reports as required.
• S/he creates user manuals; gives training, describes the entire facilities offer by the system and provides
facilities to make effective use.
• S/ he have responsibility to maintain database security, backup-recovery strategy, and documentation of
data dictionary.
• S/ he supervising all the activities in the system: the addition, modification and deletion data from the
database.
Other Database Related Terms:
1. Data Dictionary: A data dictionary is a file which contains meta-data that is data about data. It is also called
information system catalogue. It keeps all the information about the database system such as location, size of the
database, tables, records, fields, user information, privileges, backup system, and recovery system etc. It also defines
the data types for each fields etc. A good data dictionary always ensures the consistency in database.
2. Data Integrity: Data Integrity referees to the validity or consistency of data in database. It ensures that the data
should be accurate and consistent. Data should be consistent and accurate as it is the basic element of database to
provide right information at right time, to take right decision and to make right planning for future. 30, data integrity
is an important step in database designing and proper decision making. If the data integrity is not maintained in a
database, then the database may have the following drawbacks.
• The unrelated data may be stored in the master and child table.
• The improper data may be stored in the column. . The data may not come from a defined domain (set of
defined data). For example: 'age' field of 'employee’ table having 500 as the data value.
• The data may not match the business rules of the business house. For example: age of an employee never is
255.
• The changes made in one table may not bring the necessary changes in other tables. For example when
’sold quantity’ of an item is inserted in ’sales’ table, then the ’stock quantity' in ’stock’ table may remain
constant.
Data Integrity Constraints:
Data integrity is preserved by using types of constraints (rules) called data integrity constraints. Mainly
there are three types of constraints are used in database system: Domain Integrity, Entity Integrity and Referential
Integrity
23 | P a g e

1 Domain Integrity Constraints: Domain integrity constraints define a set range of data values for given specific
data field. And also determines whether null values are allowed or not in the data field. For example domain
integrity checks the marks of English of students are in the range of 0 to 100 or not.
2 Entity Integrity Constraints: Entity integrity constraints specify that all rows in a table have a unique identifier,
known as the primary key value and it never be null i.e. blank. When we change the primary key value in master
table, then related key value in child table will be automatically changed. For example: entity integrity checks
whether the ’Registration no’ of two students have same value or not.
3 Referential Integrity Constraints: It exists in a relationship between the two tables in a database. It ensures that
the relationship between the primary keys in the master table and foreign key in child table are always maintained.
So it ensures that all foreign key values in a database are valid and they are referenced by the primary key values.
For example: the data value for the ’symbol no’ field in ’student’ entity and ’result’ entity should be same.

Structured Query Language:


SQL stands for Structured Query Language. It is international standard database query language for accessing and
managing data in the database. SQL was introduced and developed by IBM in early 1970s. IBM was able to
demonstrate SQL which could be used to control relational databases. SQL is not a complete programming
languages, it is only used for communicating with database. It provides platform which allows the user to query a
database without getting depth knowledge of the design of the underlying tables. SQL has statements for data
definition, data manipulation and data control. A query is a request to the DBMS for the retrieval, modification,
insertion and deletion of the data from the database.
SQL (Structured Query Language) Pronounced as ”See”-”Quell” is made of three sub languages DDL, DML and DCL.

Basic Structure of SQL


To create a table CREATE table table_name (fieldl data_type, fie1d2 data_type, ............. )
For example: CREATE table Student (Sld NUMBER (4), Name CHAR (25));

To insert records into a table Student


INSERT into table name
VALUES(List of Values)
For example: INSERT into Student
VALUES(22, 'Ram')

To display record from table


SELECT field1,field2…………
FROM table name
For example: SELECT SId, Name from Student

DDL(Data Definition Language)


DDL is used by the database designer and programmers to specify the content and structure of the table. It is used
to define the physical characteristics of records. It includes commands that manipulate the structure of objects
such as Views, Tables, and Indexes etc. Examples of these Commands are Create, Alter, Drop, Rename etc.
To create a table CREATE table table__name (fieldl data__type, fiele datajype, . ........ ....);
24 | P a g e

For example: CREATE table Student (SId NUMBER (4), Name CHAR (25));

DML (Data Manipulation Language):


DML is related with manipulation of records such as retrieval, sorting, display and deletion of records or data. It
helps user to use query and display reports of the table. So, it provides techniques for processing the database. It
includes commands to manipulate the information stored in the databases. Examples of these Commands are
Insert, Delete, Select and Update etc. To insert records into a table Student INSERT into table name VALUES (List of
values); For example: INSERT into Student VALUES (2, ’Ram’);

DCL (Data Control Language): DCL provides additional features for security of table/ database. It includes
commands for controlling data and access to the databases. Examples of these Commands are Commit, Rollback,
Grant etc. Database Architecture The database architecture describes the organization of all database objects and
how they work together. It affects integrity, reliability and performance. The database architecture involves
anything that defines the nature of the data, the structure of the data, or how the data flows.

Difference between black box testing and white box testing.


Black Box Testing White Box Testing
Black box testing is the Software testing method which White box testing is the software testing method in which
1 is used to test the software without knowing the internal internal structure is being known to tester who is going to test
structure of code or program. the software.
Generally, this type of testing is carried out by software
2 This type of testing is carried out by testers.
developers.
Implementation Knowledge is not required to carry out Implementation Knowledge is required to carry out
3
Black Box Testing. White Box Testing.
Programming Knowledge is not required to carry out Programming Knowledge is required to carry out White Box
4
Black Box Testing. Testing.
Testing is applicable on higher levels of testing like Testing is applicable on lower level of testing like Unit
5
System Testing, Acceptance testing. Testing, Integration testing.
Black box testing means functional test or external
6 White box testing means structural test or interior testing.
testing.
In White Box testing is primarily concentrate on the testing of
In Black Box testing is primarily concentrate on the
7 program code of the system under test like code structure,
functionality of the system under test.
branches, conditions, loops etc.
The main aim of this testing to check on what The main aim of White Box testing to check on how System
8
functionality is performing by the system under test. is performing.
Black Box testing can be started based on Requirement White Box testing can be started based on Detail Design
9
Specifications documents. documents.
The Structural testing, Logic testing, Path testing, Loop
The Functional testing, Behavior testing, Close box
testing, Code coverage testing, Open box testing is carried out
10 testing is carried out under Black Box testing, so there
under White Box testing, so there is compulsory to know
is no required of the programming knowledge.
about programming knowledge.
25 | P a g e

Assignment:
• Who is DBA? Explain the responsibilities of DBA.
• Define RDBMS. Explain advantages and disadvantages of database.
• What are domains and tuples?
• State different types of data integrity.
• What is normalization? Explain normalization with example.
• -
• -
• -
• -
• -
• -
• -
• -
• -
• -

Difference between DBMS and RDBMS.


No. DBMS RDBMS
1) DBMS applications store data as file. RDBMS applications store data in a tabular form.
In DBMS, data is generally stored in either a In RDBMS, the tables have an identifier called primary key and
2)
hierarchical form or a navigational form. the data values are stored in the form of tables.
3) Normalization is not present in DBMS. Normalization is present in RDBMS.
RDBMS defines the integrity constraint for the purpose of
DBMS does not apply any security with
4) ACID (Atomicity, Consistency, Isolation and Durability)
regards to data manipulation.
property.
in RDBMS, data values are stored in the form of tables, so a
DBMS uses file system to store data, so there
5) relationship between these data values will be stored in the form
will be no relation between the tables.
of a table as well.
DBMS has to provide some uniform methods RDBMS system supports a tabular structure of the data and a
6)
to access the stored information. relationship between them to access the stored information.
DBMS does not support distributed
7) RDBMS supports distributed database.
database.
DBMS is meant to be for small organization
RDBMS is designed to handle large amount of data. it supports
8) and deal with small data. it supports single
multiple users.
user.
9) Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql server, oracle etc.

Domains and Tuples


In data management and database analysis, a data domain refers to all the values which a data element may contain.
The rule for determining the domain boundary may be as simple as a data type with an enumerated list of values.
26 | P a g e

Tuple is the collection of information about the attributes of table for single instance. In simple this also can be called
as a 'row' in a Table

Concept of OOP (Object Oriented Programming)

Stands for "Object-Oriented Programming". OOP refers to a programming methodology based on objects,
instead of just functions and procedures. These objects are organized into classes, which allow individual
objects to be group together. Most modern programming languages including Java, C/C++, and PHP, are
object-oriented languages, and many older programming languages now have object-oriented versions.

An "object" in an OOP language refers to a specific type, or "instance," of a class. Each object has a
structure similar to other objects in the class, but can be assigned individual characteristics. An object can
also call functions, or methods, specific to that object. For example, the source code of a video game may
include a class that defines the structure of characters in the game. Individual characters may be defined as
objects, which allows them to have different appearances, skills, and abilities. They may also perform
different tasks in the game, which are run using each object's specific methods.
27 | P a g e

Object-oriented programming makes it easier for programmers to structure and organize software programs.
Because individual objects can be modified without affecting other aspects of the program, it is also easier
to update and change programs written in object-oriented languages. As software programs have grown
larger over the years, OOP has made developing these large programs more manageable.
In object oriented programming
• Bottom-up approach is followed in program design.
• New data and functions can be easily added whenever necessary.
• Data is hidden cannot be accessed by external functions.
• Functions that operate on the data of an object are tied together in the data structure.
• Data structures are designed such that they characterize the objects.
• Programs are divided into objects.
• Emphasis is on data rather than procedure.
• Objects may communicate with each other through functions.
• Data structures are designed such that they characterize the objects.

Advantages of OOP:
• We can eliminate redundant codes by using inheritance feature of OOP.
• It is very easy for managing complex and large size problems.
• The most important is the reusability of codes by using the features inheritance.
• It takes very less time for the development and maintaining the software.
• It is efficient for testing and implementation of the system.
• It follows bottom up approach; It can be implemented in the field 0f OODBMS (Object Oriented
Database Management System), OOAD (Object Oriented Analysis and Design) and other different
fields of engineering.

Disadvantages of OOP:

Object Oriented Programming has several disadvantages which made it unpopular in the early years.

• Size: Object Oriented programs are much larger than other programs. In the early days of computing,
space on hard drives, floppy drives and in memory was at a premium. Today we do not have these
restrictions.
• Effort: Object Oriented programs require a lot of work to create. Specifically, a great deal of
planning goes into an object oriented program well before a single piece of code is ever written.
Initially, this early effort was felt by many to be a waste of time. In addition, because the programs
were larger (see above) coders spent more time actually writing the program.
• Speed: Object Oriented programs are slower than other programs, partially because of their size.
Other aspects of Object Oriented Programs also demand more system resources, thus slowing the
program down.

In recent years, however, improvements in computer performance have made restrictions about size and
speed inconsequential. The question of human effort still exists, however; many novice programmers do not
like Object Oriented Programming because of the great deal of work required to produce minimal results.
28 | P a g e

Concepts of OOP:

• Object:
An object is any entity, thing or organization
that exits in real world. It consists of two
fundamentals characteristics: its attributes
and behaviors. For example: a dog is an
object having attributes such as color,
weight, age, etc. and behaviors such as
barking, wagging tail, etc. In OOP, attributes
are represented by data and behaviors are
represented by functions.

• Class:

A class is the collection of similar objects. It is defined as the template or prototype to define the
common attributes and behavior for all the objects of the class. The entire set of data and code of an
object can be made a user-defined data type with the help of a class. In fact objects are variables of
type class. Once, a class has been defined,, we can create any number of objects associated with that
class.

• Abstraction:
In OOP, data abstraction defines the conceptual boundaries of an object. These boundaries
distinguish an object from another object. So, abstraction is the act of representing essential features
without including the background details. It focuses the outside view of an object, separating its
essential behaviour from its implementation.

• Encapsulation:
Encapsulation is a way if organizing data and function into a structure by concealing the way the
object is implemented, that is preventing access to data by any means other than those specified.
Encapsulation therefore guarantees the integrity of the data contained in the object. It implies that
there is visibility to the functionalities offered by an object, and no visibility to its data
• Inheritance:
In object-oriented programming, inheritance enables new objects to take on the properties of existing
objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that
inherits from a superclass is called a subclass or derived class. The terms parent class and child class are also
acceptable terms to use respectively. A child inherits visible properties and methods from its parent while
adding additional properties and methods of its own.
• Polymorphism:
The term polymorphism is formed by the combination of two Greek words: poly (means many) and
morph (means form). So, the meaning of polymorphism is having many forms. It simply means 'one
name many form'. For examples, in chemistry, carbon exhibits polymorphism because it can be
found in more than one form: graphite and diamond. Each of the form has its own distinct
properties. Polymorphism is an important feature of GOP which refers to the ability of an object to
29 | P a g e

take on different forms depending upon situations. An operation may exhibit different behaviors in
different instances. The behavior depends upon the types of data used in the operation.

Application of OOP :
The concept of object helps to translate our thoughts to a program. It provides a way of solving a problem in the same
way as a human being perceives a real world problem and finds out the solution. It is possible to construct large
reusable components using object-oriented techniques. Development of reusable components is rapidly growing in
commercial software industries.
If there is complexity in software development, object-oriented programming is the best paradigm to solve the
problem. The following areas make the use of OOP:
✓ Image Processing and Pattern Recognition
✓ Computer Aided Design and Manufacturing
✓ Object Oriented Database Management Systems
✓ Internet and Web based Applications
✓ Mobile Computing
✓ Data Warehouse and Data Mining
✓ Digital Electronics
Differences between OOP and Structured programming language:
Object Oriented Programming Language. Structure Programming Language.

OOP focus on representing problems using real-world It deals with organizing the program in the logical structure.
objects and their behavior.

Large programs are divided into objects. Large programs are divided into functions.

It uses bottom up approach of program development. It uses top down approach of program development.

Data and functions are tied together so they can't move Data move openly around the system from function to
freely. function.

The concept of encapsulation provides high level of security. Security can't be maintained because it has no such features.

New features and functions can easily be added whenever Adding new data and functions is difficult and time
required. consuming.

Developing program using OOP language is quite easier and Developing program using SPL is difficult and more time
less time consuming. consuming.

It consists of features such as data abstraction, It does not consist of those features.
encapsulation, inheritance and polymorphism.

Example: C++, Java, VB.net, C#, Python, Eiffel, Ada, etc. Examples: Pascal, C, FORTRAN, COBOL, Q-BASIC, etc.

ICT and CYBER LAW


Computer ethics and Commandments of computer ethics
Ethics deals with placing a value on acts according to whether they are good or bad. Computer and information ethics
can be understood as that branch of applied ethics which studies and analyzes such social and ethical impacts of ICT.
Commandments:
Do not use a computer to harm other people
30 | P a g e

Do not interfere with other people's computer work


Do not snoop or view around in other people's files
Do not use a computer to steal
Do not use or copy software for which you have not paid
Do not use other people's computer resources without authorization
Think about the social consequences of the program you write
Use a computer in ways that show consideration and respect

Intellectual property (IP)


Intellectual property (IP) refers to creations of the mind: inventions, literacy and artistic works, and symbols, names,
images, and designs used in commerce. IP is divided into two categories: industrial property and copyright.

Anonymity and privacy


Anonymity means that the person does not expose his or her identity. It means outsiders cannot trace, link or observe
the contents of the messages.
Privacy is the interest that the individuals have in sustaining a personal space, free from interference by other people
and organizations.

Cyber law
Cyber law is a type of law which rules in the internet to prevent internet related crime.
Fields of cyber law
Electronic and digital signature
Computer crime
Intellectual property
Data protection and privacy
Telecommunication law
Cyber law of Nepal
Nepal cannot be isolated from emerging technology and the problems raised by the technology. The cyber law is on
the process of development. Nepal passed the Electronic Transaction and Digital Signature Act 2004, also known as
Cyber law.
The main laws are:
The law covers most of the issues related with cyber activities and is supposed to forecast to be landmark legislation
for development of IT industry in Nepal.
Conducts such as hacking, deleting data, stealing e-document, software piracy and posting offensive information are
capable of criminal and civil sanctioning under the new cyber law.
The government can punish cyber offenders with up to 5 years of imprisonment and /or fine of up to Rs. 50,000.
However, much depends on the harshness of the crime.
The law has tightened the security for banking transactions through electronics means, which should boost the
economic activities across the internet via Nepal.
It gives legal status to information posted on the websites of government offices, government run corporations and
local bodies.
It has also granted legal status to digital signatures sent through the electronic media like e-banking, e-commerce, etc.
The law has also made a new judicial body to listen to complaints, cases and matters concerning cyber crime.

Computer Crime
Computer crime has been defined broadly as a criminal act that has been committed using a computer as the primary
tool.
31 | P a g e

Forms of computer crime


The theft of money, for example, the transfer of payments to the wrong accounts
The theft of information, for example, by tapping into data transmission lines or databases at no cost.
The theft of goods by their diversion to the wrong destination
The theft of computer time, for example, use of an employer's computer resources for personal work.
Besides of these, computer crime can also take form of hacking, cracking, sabotage and blackmail.

IT policies
The policies of IT are the action adopted for the implementation of strategies to achieve goals and fulfill the
objectives. Some of the policies of IT are as follows:
To declare information technology sectors a prioritized sector.
To provide internet facilities to all village development committees.
To render assistance to educational institutions and encourage native and foreign training.
To computerize the records of each governmental office.
To increase the use of computers in the private sector.
To develop physical and virtual information technology park.
To use information-technology to promote e-commerce, e-education, e-health, among others.
To establish National Information Technology Centre.
To establish a national level fund by mobilizing the resources.
To establish Nepal in the global market through the use of information technology.

Artificial Intelligence
Artificial Intelligence (AI) and it's application areas
Artificial Intelligence (AI) is a branch of computer science which is concerned with programs that solves and analyze
problems intelligently.
The applications of AI are as:
Game playing: Ai emerges and gives new height for dull machines on the field of game playing. Some intelligence
programming is far better than human brain.
Expert systems: it is computer programming to make decisions in real life situations. AI based computer system can
decide and think itself for desired result what is to be happened.
Pattern detection: it detects most common patterns for authentication, for example thumb detection, iris detection, etc.
This is most widely used tools for security purpose which once stored in database.
Natural Language Processing: NLP is a branch of artificial intelligence that deals with analyzing understanding and
generating the languages that human use naturally in order to interface with computers in both written and spoken.
Automated operation: AI is used to automate satellite, space shuttle, airplane without pilot, etc. Without any technical
human being, the system automatically handle a and controls the systems that are already set in that corresponding
instruction with logics and mathematics.
Robotics: robots are used in many fields like in space, medicine, and research etc. Now a days, robots are broadly
using in surgery for operation micro level surgery for operation micro-level surgery.

components of AI
32 | P a g e

Search: this intelligence is used to search solution of particular problem like possibilities of moves on chess playing
game. Searching is very important and needs to be very fast and must search with accuracy. So AI based system is
useful for particular problem oriented search easily.
Pattern recognization: it is used to recognize some type of figures, images or audio sounds. Its application is used for
the authentication like face detection, iris detection, voice recognization, etc.
Logic generate: as the name suggest, AI is intelligence with creating logic in different problems. Logic in terms of
predicate basis or whatever, this system creates logic for solving the any kind of related problems as per the AI related
system and software.
Common sense and reasoning: the main goal of AI is to produce good reasoning power and produce logic. This
reasoning power and logic made machines like human.
Learning from experience: AI programming is built to learn from the experiences like human being. Although
learning are limited with comparison to the human beings and also depends on the programming language used.
Genetic programming: AI programs are used to solve relationship between humans. As we see in genetically there is
inheritance properties that can help the future prediction.
Neural network: AI technique that mimics the operation of the human brain that refers to nerves and neurons, and
comprises of densely interconnected processors working simultaneously that means parallel.
Ethical aspect of AI
AI can be used for good or bad. This is why it's important to think about what AI is, and how we want it to be used.
Some ethical aspects of AI are:
AI builders have an obligation not to exploit people's ignorance and make them think. AI is human.
Robots are not really your friends. They may be harmful for individuals. So developers should be ethical. Use of AI
must obey the social norms and values.
Use of AI should be under the intellectual property rights.

Contemporary Technology

e-Commerce and e-business


E-commerce refers to online transactions, buying and selling of goods and/or services over the internet.
E-business covers online transactions, but also extends to all internets based interactions with business partners,
suppliers and customers.
Advantages of e-commerce:
a. It makes buying selling procedure faster, as well as easy to find products.
b. It makes buying/selling possible 24/7.
c. There are no theoretical geographical limitations hence more reach to customers.
d. It reduces operational costs and provides better quality of services.
e. It does not require physical company set ups.
f. It is easy to start and manage a business.

Disadvantages of e-commerce:
33 | P a g e

a. Any one, good or bad can easily start a business. And there are many bad sites which eat up customer's money.
b. There is no guarantee of product quality.
c. Mechanical failures can cause unpredictable effects on the total processes.
d. As there is minimum chance of direct customer to company interactions, customer loyalty is always on a check.
e. There are many hackers who look for opportunities and thus an ecommerce site, service payment gateways all are
always prone attack.

E-learning
E-learning is a new concept of delivering digital contents in learner oriented environment using information and
communication te4chnology (ICT). Delivery of the digital content is the main characteristic of e-learning.
Advantages of e-learning:
It maintains the consistency of content.
It is easy for customization.
There is no any geographical limitation for learning.
It is quite favorable for learner as it can happen at any time and anywhere.
It reduces or eliminates travel costs to attend learning events.
It reduces or eliminates need for classroom/instructor infrastructure.

Disadvantages of e-learning:
Learners with low motivation or bad study habits may fall behind
Without the routine structures of a traditional class, students may get lost or confused about course activities and
deadlines
Students may feel isolated from the instructor and classmates
Instructor may not always be available when students are studying or need help
Slow Internet connections or older computers may make accessing course materials frustrating
Managing computer files and online learning software can sometimes seem complex for students with beginner-level
computer skills
Hands-on or lab work is difficult to simulate in a virtual classroom.
E-governance
E-governance is the application of electronic means to improve the interaction between government and citizens; and
to increase the administrative effectiveness and efficiency in the internal government operations.
Despite the government of Nepal has positively giving attention towards the development of ICTs and subsequent
implementing e-governance, a number of issues has yet addressed. Some of the challenges for successful
implementation of e-governance are presented as:
Information transparency
Legal issues
Resources availability
Infrastructure including connectivity in rural area
Capacity and awareness
Political will and government action
34 | P a g e

Advantages of E-governance
E-Governance offers many benefits and advantages for the government, corporate sector and society. E-Governance
facilitates better delivery of government services to citizens, improved interactions with business and industry, citizen
empowerment through access to information, or more efficient government management. It simplifies internal
operations and improves performance of government departments while helping all sections of society to avail
government services at lower cost with maximum ease of use.
Virtual reality
Virtual reality is a new computational paradigm that redefines the interface between human and computer becomes a
significant and universal technology and subsequently penetrates applications for education and learning.
Application fields of Virtual reality
Virtual Reality in the Military: A virtual reality simulation enables them to do so but without the risk of death or a
serious injury. They can re-enact a particular scenario, for example engagement with an enemy in an environment in
which they experience this but without the real world risks.
Virtual Reality in Education: Education is another area which has adopted virtual reality for teaching and learning
situations. The advantage of this is that it enables large groups of students to interact with each other as well as within
a three dimensional environment.
Virtual Reality in Healthcare: Healthcare is one of the biggest adopters of virtual reality which encompasses surgery
simulation, phobia treatment, robotic surgery and skills training.
Virtual Reality in Business: Many businesses have embraced virtual reality as a cost effective way of developing a
product or service. For example it enables them to test a prototype without having to develop several versions of this
which can be time consuming and expensive.
Virtual Reality in Engineering: Virtual reality engineering includes the use of 3D modelling tools and visualization
techniques as part of the design process. This technology enables engineers to view their project in 3D and gain a
greater understanding of how it works. Plus they can spot any flaws or potential risks before implementation.
Virtual Reality and Scientific Visualization: Virtual reality is being increasingly used in the field of scientific
visualization. This field is based upon using computer graphics to express complex ideas and scientific concepts, for
example molecular models or statistical results.
Virtual Reality Programming Languages: For virtual reality to be truly effective, it must have a good sense of realism.
Just on its own this is a technical challenge and, as such, virtual reality is highly demanding on many resources. From
hardware performance to the intellectual ability of the implementer of the system, how these are managed are a
massive issue.

.E-medicine
E-medicine refers to an approach that provides medical services whenever and wherever required using information
and communication technology.
With the help of this approach, even small number of doctors can provide medical service to large number of people
scattered in different locations. The people of rural areas who are unable to get service of doctors can be benefitted
from this approach. The patients share his/her medical problems to the doctors. This approach is now getting more
popularity among the doctors too. They can post their experiences and issues in the online discussion forum. Without
good facility of information and communication technology, e-medicine cannot be effective. This is the problem
facing in the developing countries like Nepal.
35 | P a g e

Impact of Robotics in human life


Positive Impacts:
Robots can provide a wide variety of benefits to society. The most prominent benefit of robots is that they allow
physical tasks to be performed at a greater speed than humans could reasonably achieve, and that tasks can be
performed by robots that are beyond the reasonable physical capabilities of humans. For example, in manufacturing,
mechanized processes allow production to take place at a great speed, with little human effort required. This allows
for the low-cost mass-production of goods. These manufacturing processes allow for great precision, and can allow
products of a very high quality to be produced.
Negative Impacts:
As they are out to use to do common tasks, Humans are increasingly becoming lazy, and thus their health is adversely
affected. Also, as robots become more and more autonomous, the chances that they commit a mistake are very high.
These mistakes can lead to serious problems if unchecked. Also, as self-learning Robots evolve, they may make
decisions that are harmful to Human beings. From another perspective, If the robots are not self-learning, they will do
jobs only which they are programmed for. Updating their functions will thus require more expertise.

Difference analog and digital single


Analog signal Digital signal
Analog signal is a continuous signal which represents Digital signals are discrete time signals generated by digital
physical measurements. modulation.
Subjected to deterioration by noise during transmission Can be noise-immune without deterioration during
and write/read cycle. transmission and write/read cycle.
More likely to get affected reducing accuracy Less affected since noise response are analog in nature
Stored in the form of wave signal Stored in the form of binary bit
Low cost and portable Cost is high and not easily portable
Example: Computers, CDs, DVDs, and other digital
Example: Human voice in air, analog electronic devices.
electronic devices.

Difference between Internet and Intranet


Internet Intranet
The Internet is a worldwide, publicly accessible series of An intranet is a private computer network that uses
interconnected computer networks transmit data by packet Internet protocols, network connectivity to securely share
switching using the standard Internet Protocol part of an organization's information or operations
Independent of the internet; however, internet is also used
This is the base, independent of the World Wide Web
parallel
Intranets are being used to deliver tools & applications,
The Internet allows computer users to connect to other
helps to improve the services provided to the users,
computers & information stores easily across the world; it
increases employees' ability to perform their jobs faster,
36 | P a g e

is also used in marketing, online chat, file transfer, etc. etc.


Internet is a public computer network Intranet is a private computer network

Difference between Structure and Union


Structure Union
The keyword struct is used to define a structure The keyword union is used to define a union.
When a variable is associated with a structure, the compiler When a variable is associated with a union, the compiler
allocates the memory for each member. The size of allocates the memory by considering the size of the
structure is greater than or equal to the sum of sizes of its largest memory. So, size of union is equal to the size of
members. The smaller members may end with unused largest member.
slack bytes.
Each member within a structure is assigned unique storage Memory allocated is shared by individual members of
area of location. union.
The address of each member will be in ascending order This The address is same for all the members of a union. This
indicates that memory for each member will start at indicates that every member begins at the same offset
different offset values. value.
Altering the value of a member will not affect other Altering the value of any of the member will alter other
members of the structure. member values.
Individual member can be accessed at a time Only one member can be accessed at a time.
Several members of a structure can initialize at once. Only the first member of a union can be initialized.

Difference Between break and continue in C


S. Break continue

1. break statement is used in switch and loops. continue statement is used in loops only.

When break is encountered the switch or loop When continue is encountered, the statements after it

2. execution is immediately stopped. are skipped and the loop control jump to next iteration.

Example:

Example: #include<stdio.h>
int main()
#include<stdio.h> {
int main() int i;
{ for(i=0;i<5;++i)
int i; for(i=0;i<5;++i) {
if(i==3)
{ if(i==3) continue;
break; printf(“%d “,i);
printf(“%d “,i); }
} return 0;
return 0; }
}
3. Output:
012 Output:
37 | P a g e

0124

OSI reference model


It is based on a proposal developed by the international organization for standardization (ISO). The model is called
ISO OSI reference model, because it deals with connecting open system i.e. the system that are open for
communication with other system.
1. Physical Layer: This layer concerned with transmission of bit it determines voltage level for 0 & 1. It also
determines the data rate of the system. This layer involves standardized protocol dealing with electrical & signaling
interface.
2. Data Link Layer: It handles error in physical layer. This layer ensures the correct delivery of frame to the
destination address. It consists of 2 parts or 2 sub-layers. i.e.
i. Logic Link Control.
ii.Media Access Control.

3. Network Layer: This layer is concerned with transmission of packet. N/w layer protocol chooses the best path to
send a package called routing. Two protocols are widely used in n/w layer.
i. X.25 Protocol
ii. Internet Protocol
4. Transport Layer: It provides the mechanism for the exchange of data between end systems. It ensures that the
data received is in fact in order. Following jobs are performed by this layer.
i. Port Addressing
ii. Segmentation & Reassemble
iii. Connection Control
5. Session Layer: It is responsible for requesting logical connection to be established for communication process.
This logical connection is termed as session. It also provides data synchronization between two communication
terminals.
6. Presentation layer: This layer translates format data to adapt to the needs of the application layer & nodes at both
receiving & sending end of communication process. It handles data communication, formatting, encryption,
decryption, etc.
7. Application Layer: It is the top-most layer of OSI model & provides user access to the n/w. It provides services
that support user application, such as database access, email & file transfer, etc.
IP address: this is a code made up of numbers separated by three dots that identifies a particular computer on the
Internet. Every computer, whether it is a Web server or the computer you're using right now, requires an IP address to
connect to the Internet. IP addresses consist of four sets of numbers from 0 to 255, separated by three dots. For
example "66.72.98.236" or "216.239.115.148". Your Internet Service Provider (ISP), will assign you either a static IP
address (which is always the same) or a dynamic IP address, (which changes every time you log on).
MAC address: Stands for "Media Access Control Address," and no, it is not related Apple Macintosh computers. A
MAC address is a hardware identification number that uniquely identifies each device on a network. The MAC
address is manufactured into every network card, such as an Ethernet card or Wi-Fi card, and therefore cannot be
changed.
Repeater: Network repeaters regenerate incoming electrical, wireless or optical signals. With physical media like
Ethernet or Wi-Fi, data transmissions can only span a limited distance before the quality of the signal degrades.
Repeaters attempt to preserve signal integrity and extend the distance over which data can safely travel.
Bridge: In telecommunication networks, a bridge is a product that connects a local area network (LAN) to another
local area network that uses the same protocol (for example, Ethernet or token ring). You can envision a bridge as
being a device that decides whether a message from you to someone else is going to the local area network in your
building or to someone on the local area network in the building across the street. A bridge examines each message
38 | P a g e

on a LAN, "passing" those known to be within the same LAN, and forwarding those known to be on the other
interconnected LAN (or LANs).
Protocol: A standard set of regulations and requirements that allow two electronic items to connect to and exchange
information with one another. Protocols regulate data transmission among devices as well as within a network of
linked devices through both error control and specifying which data compression method to use. In particular,
protocols decide: the method of error checking, how to compact data (if required), how the transmitting device signals
that it has concluded sending data, and how the receiving device signals that it has completed receiving data.
Wi-Fi: Wi-Fi is the name of a popular wireless networking technology that uses radio waves to provide wireless high-
speed Internet and network connections. A common misconception is that the term Wi-Fi is short for "wireless fidelity,"
however this is not the case. Wi-Fi is simply a trademarked phrase that means IEEE 802.11x.

C Programming

C Programming Language

C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT
&T's Bell Laboratories in the 1972s in USA.
It is also called as 'Procedure oriented programming language.'
C is not specially designed for specific applications areas like COBOL (Common Business-Oriented
Language) or FORTRAN (Formula Translation). It is well suited for business and scientific applications. It
has some various features like control structures, looping statements, arrays, macros required for these
applications.
The C language has following numerous features as:
• Portability
• Flexibility
• Effectiveness and efficiency
• Reliability
• Interactivity
Execution of C Program :
C program executes in following 4 (four steps).

1. Creating a program :
An editor like notepad or wordpad C Editor is used to create a C program. This file contains a source code
which consists of executable code. The file should be saved as '*.c' extension only.
39 | P a g e

2. Compiling the program :


The next step is to compile the program. The code is compiled by using compiler. Compiler converts
executable code to binary code i.e. object code.
3. Linking a program to library :
The object code of a program is linked with libraries that are needed for execution of a program. The linker
is used to link the program with libraries. It creates a file with '*.exe' extension.
4. Execution of program :
The final executable file is then run by dos command prompt or by any other software.

History of C :

Year of
Language Name Developed By
Establishment

1960 ALGOL-60 Cambridge University

CPL (Combined Programming


1963 Cambridge University
Language)

BCPL (Basic Combined Programming Martin Richard at Cambridge


1967
Language) University

Ken Thompson at AT & T's Bell


1970 B
Laboratories.

Dennis Ritchie at AT & T' Bell


1972 C
Laboratory.

The development of C was a cause of evolution of programming languages like Algol 60, CPL
(Combined Programming Langauge), BCPL (Basic Combined Programming Language) and B.

• Algol-60 : (1963) :
ALGOL is an acronym for Algorithmic Language. It was the first structured procedural
programming language, developed in the late 1950s and once widely used in Europe. But it was
too abstract and too general structured langauage.
• CPL : (1963) :
CPL is an acronym for Combined Programming Language. It was developed at Cambridge
University.
• BCPL : (1967) :
BCPL is an acronym for Basic Combined Programming Language. It was developed by Martin
Richards at Cambridge University in 1967. BCPL was not so powerful. So, it was failed.
• B : (1970) :
B language was developed by Ken Thompson at AT & T Bell Laboratories in 1970. It was machine
dependent. So, it leads to specific problems.
40 | P a g e

• C : (1972) :
'C' Programming Langauage was developed by Dennis Ritchie at AT & T Bell Laboratories in
1972. This is general purpose, compiled, structured programming langauage. Dennis Ritchie
studied the BCPL, then improved and named it as 'C' which is the second letter of BCPL

Structure of C Program
The basic structure of C program is as follow:
Document Section
Links Section (File)
Definition Section
Global variable declaration Section
void main()
{
Variable declaration section
Function declaration section
executable statements;
}
Function definition 1
---------------------
---------------------
Function definition n where,
Document Section : It consists of set of comment lines which include name of a program, author
name, creation date and other information.
Links Section (File) : It is used to link the required system libraries or header files to excute a
program.
Definition Section : It is used to define or set values to variables.
Global variable declaration Section : It is used to declare global or public variable.
void main() : Used to start of actual C program. It includes two parts as declaration part and
executable part.
Variable declaration section : Used to declare private variable.
Function declaration section : Used to declare functions of program from which we get required
output.
Then, executable statements are placed for execution.
Function definition section : Used to define functions which are to be called from main().

Character Set :
A character refers to the digit, alphabet or special symbol used to data represetation.
1. Alphabets : A-Z, a-z
2. Digits : 0-9
3. Special Characters : ~ ! @ # $ % ^ & * ( ) _ + { } [ ] - < > , . / ? \ | : ; " '
4. White Spaces : Horizontal tab, Carriage return, New line, form feed

Identifier :
Identifier is the name of a variable that is made up from combination of alphabets, digits and
underscore.

Variable :
41 | P a g e

It is a data name which is used to store data and may change during program execution. It is
opposite to constant. Variable name is a name given to memory cells location of a computer
where data is stored.
* Rules for varibales:
• First character should be letter or alphabet.
• Keywords are not allowed to use as a variable name.
• White space is not allowed.
• C is case sensitive i.e. UPPER and lower case are significant.
• Only underscore, special symbol is allowed between two characters.
• The length of indentifier may be upto 31 characters but only only the first 8 characters are
significant by compiler.
• (Note: Some compilers allow variable names whose length may be upto 247 characters.
But, it is recommended to use maximum 31 characters in variable name. Large variable name
leads to occur errors.)

Keywords :
Keywords are the system defined identifiers.
All keywords have fixed meanings that do not change.
White spaces are not allowed in keywords.
Keyword may not be used as an indentifier.
It is strongly recommended that keywords should be in lower case letters.
There are totally 32(Thirty Two) keywords used in a C programming.
int float double long
short signed unsigned const
if else switch break
default do while for
register extern static struct
typedef enum return sizeof
goto union auto case
void char continue volatile

Escape Sequence Characters (Backslash Character Constants) in C:


C supports some special escape sequence characters that are used to do special tasks.
These are also called as 'Backslash characters'.
Some of the escape sequence characters are as follow:

Character Constant Meaning

\n New line (Line break)

\b Backspace

\t Horizontal Tab
42 | P a g e

\f Form feed

\a Alert (alerts a bell)

\r Carriage Return

\v Vertical Tab

\? Question Mark

\' Single Quote

\'' Double Quote

\\ Backslash

\0 Null

Constants in C :
A constant is an entity that doesn't change during the execution of a program.
Followings are the different types of constants :
1. REAL CONSTANT :
• It must have at least one digit.
• It must have a decimal point which may be positive or negative.
• Use of blank space and comma is not allowed between real constants.
• Example:

+194.143, -416.41
2. INTEGER CONSTANT :
• It must have at least one digit.
• It should not contain a decimal place.
• It can be positive or negative.
• Use of blank space and comma is not allowed between real constants.
• Example:

1990, 194, -394


3. CHARACTER CONSTANT :
• It is a single alphabet or a digit or a special symbol enclosed in a single quote.
• Maximum length of a character constant is 1.
• Example:

'T', '9', '$'


43 | P a g e

4. STRING CONSTANT :
• It is collection of characters enclosed in double quotes.
• It may contain letters, digits, special characters and blank space.
• Example:

"Depot School"

Data Types in C :
"Data type can be defined as the type of data of variable or constant store."
When we use a variable in a program then we have to mention the type of data. This can be
handled using data type in C.
Followings are the most commonly used data types in C.

Keyword Format Specifier Size Data Range

char %c 1 Byte -128 to +127

unsigned char 8 Bytes 0 to 255

int %d 2 Bytes -32768 to +32767

long int %ld 4 Bytes -231 to +231

unsigned int %u 2 Bytes 0 to 65535

float %f 4 Bytes -3.4e38 to +3.4e38

double %lf 8 Bytes -1.7e38 to +1.7e38

long double %Lf 12-16 Bytes -3.4e38 to +3.4e38

* QUALIFIER :
When qualifier is applied to the data type then it changes its size.
Size qualifiers : short, long
Sign qualifiers : signed, unsigned

* ENUM DATA TYPE :


This is an user defined data type having finite set of enumeration constants. The keyword 'enum'
is used to create enumerated data type.
Syntax:
44 | P a g e

enum [data_type] {const1, const2, ...., const n};

Example:
#include <stdio.h>
int main()
{
enum Days{Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday};
Days TheDay;
int j = 0;
printf("Please enter the day of the week (0 to 6)\n");
scanf("%d",&j);
TheDay = Days(j);
if(TheDay == Sunday || TheDay == Saturday)
printf("Hurray it is the weekend\n");
else
printf("Curses still at work\n");
return 0;
}
* TYPEDEF :
It is used to create new data type. But it is commonly used to change existing data type with
another name.
Syntax:
typedef [data_type] synonym;
OR typedef [data_type] new_data_type;
Example:
#include <stdio.h>
void main ()
{
typedef int my_type;
my_type var1, var2, var3;
var1 = 10;
var2 = 20;
var3 = 30;
}
Operators in C :
"Operator is a symbol that is used to perform mathematical operations."
When we use a variable in a program then we have to mention the type of data. This can be
handled using data type in C.
Followings are the most commonly used data types in C.

Operator Name Operators Example

#include <stdio.h>
#include <conio.h>
Assignment = void main()
{
45 | P a g e

int a,b;
clrscr();
a = 53;
printf("\n\t Value of A :
%d",a); // 53
b = a; // Interchange of value
using assignment
printf("\n\n\t Value of B :
%d",b); // 53
getch();
}

#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c,d,e,f,g;
clrscr();
printf("\n\t Enter First Number
:"); // 5
scanf("%d",&a);
printf("\n\t Enter Second
Number :"); // 2
scanf("%d",&b);
c = a + b;
printf("\n\n\t Addition is :
Arithmetic +, -, *, /, % %d",c); // 7
d = a - b;
printf("\n\n\t Subtraction is :
%d",d); // 3
e = a * b;
printf("\n\n\t Multiplication
is : %d",e); // 10
f = a / b;
printf("\n\n\t Division is :
%d",f); // 2
g = a % b;
printf("\n\n\t Modulus is :
%d",g); // 1
getch();
}

#include <stdio.h>
Logical &&, ||, ! #include <conio.h>
46 | P a g e

void main()
{
int no1=2, no2=5;
clrscr();
printf("\n\n %d",(no1 &&
no2)); // returns 1
printf("\n\n %d",(no1 ||
no2)); // returns 1
getch();
}

#include <stdio.h>
#include <conio.h>

void main()
{
int a=6, b=2;
clrscr();
Relational <, >, <=, >=, ==, != printf("\n\n A<=B :
%d",(a<=b)); // 0 - False
printf("\n\n A>B : %d",(a>b));
// 1 - True
printf("\n\n A!=B :
%d",(a!=b)); // 1 - True
getch();
}

#include <stdio.h>
#include <conio.h>
void main()
{
int a,b;
clrscr();
a = 18;
b = 4;
printf("\n\t Value of A :
Shorthand +=, -=, *=, /=, %= %d",a); // 18
printf("\n\t Using of B :
%d",b); // 4
b += a ; // b = b + a
printf("\n\n\t Using += (i.e
b=b+a): %d",b); // 22
// Change the operator as -=,
*=, /=, %=
getch();
}
47 | P a g e

#include <stdio.h>
#include <conio.h>

void main()
{
int a=4, b;
clrscr();
printf("\n\n Value of A :
%d",a); // 4
a++; // Post
printf("\n\n Value of A :
%d",a); // 5
++a; // Pre
printf("\n\n Value of A :
%d",a); // 6
Unary ++, -- b=--a;
printf("\n\n Value of A :
%d",a); // 5
printf("\n\n Value of B :
%d",b); // 5
b=a++;
printf("\n\n Value of A :
%d",a); // 6
printf("\n\n Value of B :
%d",b); // 5
b++;
printf("\n\n Value of B :
%d",b); // 6
getch();
}

#include <stdio.h>
#include <conio.h>
void main()
{
int a, b=3;
clrscr();
a = 5;
Conditional ()?:; printf("\n\n A is less than B ?
");

// No
getch();
}
48 | P a g e

#include <stdio.h>
#include <conio.h>
void main()
{
int a=2, b=3,c;
Bitwise &, |, ^, <<, >>, ~ clrscr();
c =a|b;
printf("\n%d\n",c);
getch();
}

Operators Precedence and Associativity :


In C, each and every operator has a spcial precedence which is associated with it. There are
various levels of precedence. This precedence is especially used to determine to evaluation of
expression which has more than one operator in it. The operators which has higher precedence
are executed first and vice-versa. Operators which has same precedence level are evaluated from
left to right. It is dependant on it's level. This feature is well known as 'Associativity of an
operator.'
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type) * & sizeof Right to left
Multiplicative * / % Left to right
Additive +- Left to right
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
Bitwise XOR ^ Left to right
Bitwise OR | Left to right
Logical AND && Left to right
Logical OR || Left to right
Conditional ?: Right to left
Assignment = += -= *= /= %= >>= <<= &= ^= |= Right to left
Comma , Left to right
Fig.: Precedence and Associativity of operators
Decision Making Statements / Conditional Statements :
C program executes program sequentially. Sometimes, a program requires checking of certain
conditions in program execution. C provides various key condition statements to check condition
and execute statements according conditional criteria.
These statements are called as 'Decision Making Statements' or 'Conditional Statements.'
Followings are the different conditional statements used in C.
1. If Statement
49 | P a g e

Syntax:

if(condition)
{
statements;
}

Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
a=5;
clrscr();
if(a>4)
printf("\nValue of A is greater than 4 !");
if(a==4)
printf("\n\n Value of A is 4 !");
getch();
}

2. If-Else Statement

Syntax:

if(condition)
{
true statements;
}
else
{
false statements;
}
Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int no;
clrscr();
printf("\n Enter Number :");
scanf("%d",&no);
if(no%2==0)
printf("\n\n Number is even !");
else
printf("\n\n Number is odd !");
getch();
50 | P a g e

3. Nested If-Else Statement

It is a conditional statement which is used when we want to check more than 1 conditions at a
time in a same program. The conditions are executed from top to bottom checking each condition
whether it meets the conditional criteria or not. If it found the condition is true then it executes the
block of associated statements of true part else it goes to next condition to execute.
Syntax:

if(condition)
{
if(condition)
{
statements;
}
else
{
statements;
}
}
else
{
statements;
}

Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int no;
clrscr();
printf("\n Enter Number :");
scanf("%d",&no);
if(no>0)
{
printf("\n\n Number is greater than 0 !");
}
else
{
if(no==0)
{
printf("\n\n It is 0 !");
}
else
{
printf("Number is less than 0 !");
51 | P a g e

}
}
getch();
}

4. Switch Case

This is a multiple or multiway brancing decision making statement.


When we use nested if-else statement to check more than 1 conditions then the complexity of a
program increases in case of a lot of conditions. Thus, the program is difficult to read and
maintain. So to overcome this problem, C provides 'switch case'.
Switch case checks the value of a expression against a case values, if condition matches the case
values then the control is transferred to that point.

Syntax:

switch(expression)
{
case expr1:
statements;
break;
case expr2:
statements;
break;

case exprn:
statements;
break;
default:
statements;
}
In above syntax, switch, case, break are keywords.
expr1, expr2 are known as 'case labels.'
Statements inside case expression need not to be closed in braces.
Break statement causes an exit from switch statement.
Default case is optional case. When neither any match found, it executes.
Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int no;
52 | P a g e

clrscr();
printf("\n Enter any number from 1 to 3 :");
scanf("%d",&no);
switch(no)
{
case 1:
printf("\n\n It is 1 !");
break;
case 2:
printf("\n\n It is 2 !");
break;
case 3:
printf("\n\n It is 3 !");
break;
default:
printf("\n\n Invalid number !");
}
getch();
}

* RULES FOR DECLARING SWITCH CASE :


• The case label should be integer or character constant.
• Each compound statement of a switch case should contain break statement to exit from
case.
• Case labels must end with (:) colon.
* ADVANTAGES OF SWITCH CASE :
• Easy to use.
• Easy to find out errors.
• Debugging is made easy in switch case.
• Complexity of a program is minimized.

Looping Statements / Iterative Statements :


'A loop' is a part of code of a program which is executed repeatedly.
A loop is used using condition. The repetition is done until condition becomes condition true.
A loop declaration and execution can be done in following ways.
• Check condition to start a loop
• Initialize loop with declaring a variable.
• Executing statements inside loop.
• Increment or decrement of value of a variable.
* TYPES OF LOOPING STATEMENTS :
Basically, the types of looping statements depends on the condition checking mode. Condition
checking can be made in two ways as : Before loop and after loop. So, there are 2(two) types of
looping statements.
• Entry controlled loop
• Exit controlled loop
1. Entry controlled loop :
In such type of loop, the test condition is checked first before the loop is executed.
53 | P a g e

Some common examples of this looping statements are :

for loop

This is an entry controlled looping statement.


In this loop structure, more than one variable can be initilized. One of the most important feature
of this loop is that the three actions can be taken at a time like variable initilisation, condition
checking and increment/decrement. The for loop can be more concise and flexible than that of
while and do-while loops.
Syntax:

for(initialisation; test-condition; incre/decre)


{
statements;
}

In above syntax, the given three expressions are seperated by ';' (Semicolon)
Features :
• More concise
• Easy to use
• Highly flexible
• More than one variable can be initilized.
• More than one increments can be applied.
• More than two conditions can be used.
Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
for(i=0; i<5; i++)
{
printf("\n\t FundamentalOfComputing"); // 5 times
}
getch();
}

Nested for loop


Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a,i;
clrscr();
for(i=0; i<3; i++)
{
printf("i=”%d\n”,i);
54 | P a g e

for(a=1;a<=3;a++)
{
Printf(("a=%d\n”,a);
}
}
getch();
}

while loop:

This is an entry controlled looping statement. It is used to repeat a block of statements until
condition becomes true.
Syntax:

while(condition)
{
statements;
increment/decrement;
}
In above syntax, the condition is checked first. If it is true, then the program control flow goes
inside the loop and executes the block of statements associated with it. At the end of loop
increment or decrement is done to change in variable value. This process continues until test
condition satisfies.
Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
a=1;
while(a<=5)
{
printf("\n Depot School Dharan");
a+=1 // i.e. a = a + 1
}
getch();
}

Do-While loop :
This is an exit controlled looping statement.
Sometimes, there is need to execute a block of statements first then to check condition. At that
time such type of a loop is used. In this, block of statements are executed first and then condition
is checked.
Syntax:
do
{
statements;
(increment/decrement);
55 | P a g e

}while(condition);

In above syntax, the first the block of statements are executed. At the end of loop, while statement
is executed. If the resultant condition is true then program control goes to evaluate the body of a
loop once again. This process continues till condition becomes true. When it becomes false, then
the loop terminates.
Note: The while statement should be terminated with ; (semicolon).
Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a;
clrscr();
a=1;
do
{
printf("\n\t FundamentalOfComputing"); // 5 times
a+=1; // i.e. a = a + 1
}while(a<=5);
a=6;
do
{
printf("\n\n\t Technowell"); // 1 time
a+=1; // i.e. a = a + 1
}while(a<=5);
getch();
}

Break Statement :
Sometimes, it is necessary to exit immediately from a loop as soon as the condition is satisfied.
When break statement is used inside a loop, then it can cause to terminate from a loop. The
statements after break statement are skipped.
Syntax :

break;

Figure :

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
clrscr();
56 | P a g e

for(i=1; ; i++)
{
if(i>5)
break;
printf("%d",i); // 5 times only
}
getch();
}
Output :
12345

Continue Statement :
Sometimes, it is required to skip a part of a body of loop under specific conditions. So, C supports
'continue' statement to overcome this anomaly.
The working structure of 'continue' is similar as that of that break statement but difference is that it
cannot terminate the loop. It causes the loop to be continued with next iteration after skipping
statements in between. Continue statement simply skips statements and continues next iteration.
Syntax :

continue;

Figure :

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int i;
clrscr();
for(i=1; i<=10; i++)
{
if(i==6)
continue;
printf("\n\t %d",i); // 6 is omitted
}
getch();
}
Output :
1
2
3
4
5
7
8
57 | P a g e

9
10

Goto Statement :
It is a well known as 'jumping statement.' It is primarily used to transfer the control of execution to
any place in a program. It is useful to provide branching within a loop.
When the loops are deeply nested at that if an error occurs then it is difficult to get exited from
such loops. Simple break statement cannot work here properly. In this situations, goto statement
is used.
Syntax :

goto [expr];

Figure :

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int i=1, j;
clrscr();
while(i<=3)
{
for(j=1; j<=3; j++)
{
printf(" * ");
if(j==2)
goto stop;
}
i = i + 1;
}
stop:
printf("\n\n Exited !");
getch();
}
Output :
* *
Exited

Contents :
1. Functions
2. Types of Functions :
3. Built In Functions
4. User Defined Functions
5. Function Call By Passing Value
58 | P a g e

6. Function Call By Returning Value


7. Function Call By Passing and Returning Value
8. Advantages
9. Recursion (Recursive Function)
Functions in C :
The function is a self contained block of statements which performs a coherent task of a same
kind.
C program does not execute the functions directly. It is required to invoke or call that functions.
When a function is called in a program then program control goes to the function body. Then, it
executes the statements which are involved in a function body. Therefore, it is possible to call
fuction whenever we want to process that functions statements.
Types of functions :
There are 2(two) types of functions as:
1. Built in Functions
2. User Defined Functions

1. Built in Functions :
These functions are also called as 'library functions'. These functions are provided by system.
These functions are stored in library files. e.g.
• scanf()
• printf()
• strcpy
• strlwr
• strcmp
• strlen
• strcat
1. User Defined Functions :
The functions which are created by user for program are known as 'User defined functions'.
Syntax:

void main()
{
// Function prototype
<return_type><function_name>([<argu_list>]);

// Function Call
<function_name>([<arguments>]);
}
// Function definition
<return_type><function_name>([<argu_list>]);
{
<function_body>;
}

Program :
#include <stdio.h>
#include <conio.h>

void add()
59 | P a g e

{
int a, b, c;
clrscr();
printf("\n Enter Any 2 Numbers : ");
scanf("%d %d",&a,&b);
c = a + b;
printf("\n Addition is : %d",c);
}
void main()
{
void add();
add();
getch();
}

Output :
Enter Any 2 Numbers : 23 6
Addition is : 29

Function Call by Passing Value :


When a function is called by passing value of variables then that function is known as 'function call
by passing values.'
Syntax:

// Declaration
void <function_name>(<data_type><var_nm>);

// Calls
<function_name>(<var_nm>);

// Definition
void <function_name>(<data_type><var_nm>);
{
<function_body>;
- - - - - - - -;
}
Program :
#include <stdio.h>
#include <conio.h>

void printno(int a)
{
printf("\n Number is : %d", a);
}
void main()
{
60 | P a g e

int no;
void printno(int);
clrscr();
printf("\n Enter Number : ");
scanf("%d", &no);
printno(no);
getch();
}

Output :
Enter Number : 21
Number is : 21_

Function Call by Returning Value :


When a function returns value of variables then that function is known as 'function call by returning
values.'
Syntax:

// Declaration
<data_type><function_name>();

// Calls
<variable_of_function>=<function_nm>();

// Definition
<data_type><function_name>()
{
<function_body>;
- - - - - - - -;
return <variable_of_function>;
}
Program :
#include <stdio.h>
#include <conio.h>

int number()
{
int no;
printf("\n Enter Number : ");
scanf("%d",&no);
return no;
}
void main()
{
int no;
int number();
61 | P a g e

clrscr();
no = number();
printf("\n Number is : %d",no);
getch();
}

Output :
Enter Number : 5
Number is : 5_

Function Call by Passing and Returning Value :


When a function passes and returns value of variables then that function is known as 'function call
by passing and returning values.'
Program :

/* Program to demonstrate function call by passing

#include <stdio.h>
#include <conio.h>

int number(int n)
{
return n;
}
void main()
{
int number(int);
int a = number(4);
clrscr();
printf("\n Number is : %d",a);
getch();
}

Output :

Number is : 4_

Recursion (Recursive Function) :


When a function of body calls the same function then it is called as 'recursive function.'
Example:

Recursion()
{
printf("Recursion !");
Recursion();
62 | P a g e

}
Program :
#include <stdio.h>
#include <conio.h>

Recursion()
{
int no;
printf("\nRecursion... ");
printf("\n\n Enter Number : ");
scanf("%d",&no);
if (no==3)
exit(0);
else
Recursion();
}
void main()
{
clrscr();
Recursion();
}

Output :
Recursion...
Enter Number : 2
Recursion...
Enter Number : 1
Recursion...
Enter Number : 3_

Function Advantages :
• It is easy to use.
• Debugging is more suitable for programs.
• It reduces the size of a program.
• It is easy to understand the actual logic of a program.
• Highly suited in case of large programs.
• By using functions in a program, it is possible to construct modular and structured programs.

Storage Class :
'Storage' refers to the scope of a variable and memory allocated by compiler to store that variable.
Scope of a variable is the boundary within which a varible can be used. Storage class defines the
the scope and lifetime of a variable.
63 | P a g e

From the point view of C compiler, a variable name identifies physical location from a computer
where varaible is stored. There are two memory locations in a computer system where variables
are stored as : Memory and CPU Registers.
Functions of storage class :
To detemine the location of a variable where it is stored ?
Set initial value of a variable or if not specified then setting it to default value.
Defining scope of a variable.
To determine the life of a variable.
Types of Storage Classes :
Storage classes are categorized in 4 (four) types as,

Automatic Storage Class :


• Keyword : auto
• Storage Location : Main memory
• Initial Value : Garbage Value
• Life : Control remains in a block where it is defined.
• Scope : Local to the block in which variable is declared.
Syntax :

auto [data_type] [variable_name];

Example :

auto int a;

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
auto int i=10;
clrscr();
{
auto int i=20;
printf("\n\t %d",i);
}
printf("\n\n\t %d",i);
getch();
}
Output :
20
10

Register Storage Class :


• Keyword : register
• Storage Location : CPU Register
• Initial Value : Garbage
64 | P a g e

• Life : Local to the block in which variable is declared.


• Scope : Local to the block.
Syntax :

register [data_type] [variable_name];

Example :

register int a;

When the calculations are done in CPU, then the value of variables are transferred from main
memory to CPU. Calculations are done and the final result is sent back to main memory. This
leads to slowing down of processes.
Register variables occur in CPU and value of that register variable is stored in a register within
that CPU. Thus, it increases the resultant speed of operations. There is no waste of time, getting
variables from memory and sending it to back again.
It is not applicable for arrays, structures or pointers.
It cannot not used with static or external storage class.
Unary and address of (&) cannot be used with these variables as explicitly or implicitly.

Program :
#include <stdio.h>
#include <conio.h>

void main()
{
register int i=10;
clrscr();
{
register int i=20;
printf("\n\t %d",i);
}
printf("\n\n\t %d",i);
getch();
}

Output :
20
10

Static Storage Class :


• Keyword : static
• Storage Location : Main memory
• Initial Value : Zero and can be initialize once only.
• Life : depends on function calls and the whole application or program.
• Scope : Local to the block.
Syntax :
65 | P a g e

static [data_type] [variable_name];

Example :

static int a;

There are two types of static variables as :

a) Local Static Variable


b) Global Static Variable
Static storage class can be used only if we want the value of a variable to persist between
different function calls.

Program :
#include <stdio.h>
#include <conio.h>

void main()
{
int i;
void incre(void);
clrscr();
for (i=0; i<3; i++)
incre();
getch();
}

void incre(void)
{
int avar=1;
static int svar=1;
avar++;
svar++;
printf("\n\n Automatic variable value : %d",avar);
printf("\t Static variable value : %d",svar);
}

Output :
Automatic variable value : 2 Static variable value : 2
Automatic variable value : 2 Static variable value : 3
Automatic variable value : 2 Static variable value : 4_

External Storage Class :


• Keyword : extern
• Storage Location : Main memory
• Initial Value : Zero
• Life : Until the program ends.
• Scope : Global to the program.
66 | P a g e

Syntax :

extern [data_type] [variable_name];

Example :

extern int a;

The variable access time is very fast as compared to other storage classes. But few registers are
available for user programs.
The variables of this class can be referred to as 'global or external variables.' They are declared
outside the functions and can be invoked at anywhere in a program.

Program :
#include <stdio.h>
#include <conio.h>

extern int i=10;


void main()
{
int i=20;
void show(void);
clrscr();
printf("\n\t %d",i);
show();
getch();
}
void show(void)
{
printf("\n\n\t %d",i);
}

Output :
20
10_

Array :
Array is a collection of homogenous data stored under unique name. The values in an array is
called as 'elements of an array.' These elements are accessed by numbers called as 'subscripts or
index numbers.' Arrays may be of any variable type.
Array is also called as 'subscripted variable.'
Types of an Array :
1. One / Single Dimensional Array
2. Two Dimensional Array
Single / One Dimensional Array :
The array which is used to represent and store data in a linear form is called as 'single or one
dimensional array.'
Syntax:
67 | P a g e

<data-type> <array_name> [size];

Example:

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


char ch[20] = "FundamentalOfComputing" ;
float stax[3] = {5003.23, 1940.32, 123.20} ;

Total Size (in Bytes):

total size = length of array * size of data type

In above example, a is an array of type integer which has storage size of 3 elements. The total
size would be 3 * 2 = 6 bytes.
* MEMORY ALLOCATION :

Fig : Memory allocation for one dimensional array

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a[3], i;;
clrscr();
printf("\n\t Enter three numbers : ");
for(i=0; i<3; i++)
{
scanf("%d", &a[i]); // read array
}
printf("\n\n\t Numbers are : ");
for(i=0; i<3; i++)
{
printf("\t %d", a[i]); // print array
}
getch();
}

Output :

Enter three numbers : 9 4 6

Numbers are : 9 4 6_
68 | P a g e

Features :
• Array size should be positive number only.
• String array always terminates with null character ('\0').
• Array elements are countered from 0 to n-1.
• Useful for multiple reading of elements (numbers).

Disadvantages :
• There is no easy method to initialize large number of array elements.
• It is difficult to initialize selected elements.

Two Dimensional Array :


The array which is used to represent and store data in a tabular form is called as 'two dimensional
array.' Such type of array specially used to represent data in a matrix form.
The following syntax is used to represent two dimensional array.
Syntax:

<data-type> <array_nm> [row_subscript][column-subscript];

Example:

int a[3][3];

In above example, a is an array of type integer which has storage size of 3 * 3 matrix. The total
size would be 3 * 3 * 2 = 18 bytes.
It is also called as 'multidimensional array.'
* MEMORY ALLOCATION :

Fig : Memory allocation for two dimensional array

Program :
#include <stdio.h>
#include <conio.h>
void main()
{
int a[3][3], i, j;
clrscr();
printf("\n\t Enter matrix of 3*3 : ");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
scanf("%d",&a[i][j]); //read 3*3 array
}
}
printf("\n\t Matrix is : \n");
for(i=0; i<3; i++)
69 | P a g e

{
for(j=0; j<3; j++)
{
printf("\t %d",a[i][j]); //print 3*3 array
}
printf("\n");
}
getch();
}

Output :

Enter matrix of 3*3 : 3 4 5 6 7 2 1 2 3

Matrix is :
3 4 5
6 7 2
1 2 3_

Limitations of two dimensional array :


• We cannot delete any element from an array.
• If we don’t know that how many elements have to be stored in a memory in advance, then
there will be memory wastage if large array size is specified.

Structure :
Structure is user defined data type which is used to store heterogeneous data under unique
name. Keyword 'struct' is used to declare structure.
The variables which are declared inside the structure are called as 'members of structure'.
Syntax:
struct structure_nm
{
<data-type> element 1;
<data-type> element 2;
- - - - - - - - - - -
- - - - - - - - - - -
<data-type> element n;
}struct_var;

Example :
70 | P a g e

struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
}emp;

Note :
1. Structure is always terminated with semicolon (;).
2. Structure name as emp_info can be later used to declare structure variables of its type in a
program.

* INSTANCES OF STRUCTURE :
Instances of structure can be created in two ways as,
Instance 1:

struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
}emp;

Instance 2:

struct emp_info
{
char emp_id[10];
char nm[100];
float sal;
};
struct emp_info emp;
In above example, emp_info is a simple structure which consists of stucture members as
Employee ID(emp_id), Employee Name(nm), Employee Salary(sal).
* ACEESSING STRUCTURE MEMBERS :
Structure members can be accessed using member operator '.' . It is also called as 'dot operator'
or 'period operator'.
structure_var.member;

Program :
#include <stdio.h>
#include <conio.h>

struct comp_info
{
71 | P a g e

char nm[100];
char addr[100];
}info;

void main()
{
clrscr();
printf("\n Enter Company Name : ");
gets(info.nm);
printf("\n Enter Address : ");
gets(info.addr);
printf("\n\n Company Name : %s",info.nm);
printf("\n\n Address : %s",info.addr);
getch();
}

Output :
Enter Company Name : CODES
Enter Address : Dharan-9

Company Name : CODES


Address : Dharan-9

Pointer :
Pointer is a variable which holds the memory address of another variable. Pointers are
represented by '*'. It is a derive data type in C. Pointer returns the value of stored address.
Syntax:

<data_type> *pointer_name;

In above syntax,
* = variable pointer_name is a pointer variable.
pointer_name requires memory location
pointer_name points to a variable of type data type.
How to Use ?

int *tot;

Illustration :

int tot = 95;

Figure :
72 | P a g e

In above example, the statement instructs the system to find out a location for integer variable
quantity and puts the values 95 in that memory location.
* Features of Pointer :

* Pointer variable should have prefix '*'.


* Combination of data types is not allowed.
* Pointers are more effective and useful in handling arrays.
* It can also be used to return multiple values from a funtion using function arguments.
* It supports dynamic memory management.
* It reduces complexity and length of a program.
* It helps to improve execution speed that results in reducing program execution time.

Program :
#include <stdio.h>
#include <conio.h>

void main()
{
int a=10;
int *ptr;
clrscr();
ptr = &a;
printf("\n\t Value of a : %d", a);
scanf("\n\n\t Value of pointer ptr : %d", *ptr);
printf("\n\n\t Address of pointer ptr : %d", ptr);
getch();
}

Output :

Value of a : 10

Value of pointer ptr : 10

Address of pointer ptr : -12_

Union :
Union is user defined data type used to stored data under unique variable name at single memory
location.
Union is similar to that of structure. Syntax of union is similar to structure. But the
major difference between structure and union is 'storage.' In structures, each member has its
own storage location, whereas all the members of union use the same location. Union contains
many members of different types, it can handle only one member at a time.
To declare union data type, 'union' keyword is used.
Union holds value for one data type which requires larger storage among their members.
Syntax:
73 | P a g e

union union_name
{
<data-type> element 1;
<data-type> element 2;
<data-type> element 3;
}union_variable;

Example:

union techno
{
int comp_id;
char nm;
float sal;
}tch;

In above example, it declares tch variable of type union. The union contains three members as
data type of int, char, float. We can use only one of them at a time.
* MEMORY ALLOCATION :

Fig : Memory allocation for union

To access union members, we can use the following syntax.


tch.comp_id
tch.nm
tch.sal

Program :

#include <stdio.h>
#include <conio.h>

union techno
{
int id;
char nm[50];
}tch;

void main()
{
clrscr();
printf("\n\t Enter developer id : ");
scanf("%d", &tch.id);
printf("\n\n\t Enter developer name : ");
scanf("%s", tch.nm);
printf("\n\n Developer ID : %d", tch.id);//Garbage
printf("\n\n Developed By : %s", tch.nm);
74 | P a g e

getch();
}

Output :
Enter developer id : 101

Enter developer name : technowell

Developer ID : 25972

Developed By : technowell_

String Handling in C :
String :
A string is a collection of characters. Strings are always enlosed in double quotes as
"string_constant".
Strings are used in string handling operations such as,
• Counting the length of a string.
• Comparing two strings.
• Copying one string to another.
• Converting lower case string to upper case.
• Converting upper case string to lower case.
• Joining two strings.
• Reversing string.
Declaration :
The string can be declared as follow :
Syntax:

char string_nm[size];

Example:

char name[50];

String Structure :
When compiler assigns string to character array then it automatically supplies null character
('\0') at the end of string. Thus, size of string = original length of string + 1.

char name[7];
name = "TECHNO"

Read Strings :
75 | P a g e

To read a string, we can use scanf() function with format specifier %s.

char name[50];
scanf("%s",name);

The above format allows to accept only string which does not have any blank space, tab, new line,
form feed, carriage return.
Write Strings :
To write a string, we can use printf() function with format specifier %s.

char name[50];
scanf("%s",name);
printf("%s",name);

string.h header file

'string.h' is a header file which includes the declarations, functions, constants of string handling
utilities. These string functions are widely used today by many programmers to deal with string
operations.
Some of the standard member functions of string.h header files are,
Function Name Description
strlen - Returns the length of a string.
strlwr - Returns upper case letter to lower case.
strupr - Returns lower case letter to upper case.
strcat - Concatenates two string.
strcmp - Compares two strings.
strrev - Returns length of a string.
strcpy - Copies a string from source to destination.

Program :
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char str[50];
clrscr();
printf("\n\t Enter your name : ");
gets(str);
printf("\nLower case of string: %s",strlwr(str));
printf("\nUpper case of string: %s",strupr(str));
printf("\nReverse of string: %s",strrev(str));
printf("\nLength of String: %d",strlen(str));
getch();
76 | P a g e

Output :
Enter your name : FundamentalOfComputing
Lower case of string: fundamentalofcomputing
Upper case of string: FUNDAMENTALOFCOMPUTING
Reverse of string: GNITUPMOCFOLATNEMADNUF
Length of String: 22_

FILE HANDLING IN C
To work with files, the library routines must be included into your programs. This is done by the
statement,

#include <stdio.h>
as the first statement of your program.
File operation functions in C:

Function Name Operation


fopen() Creates a new file. Opens an existing file.
fclose Closes a file which has been opened for use
getc() Reads a character from a file
putc() Writes a character to a file
fprintf() Writes a set of data values to a file
fscanf() Reads a set of data values from a file
getw() Reads a integer from a file
putw() Writes an integer to the file
fseek() Sets the position to a desired point in the file
ftell() Gives the current position in the file
rewind() Sets the position to the beginning of the file
Simple Example:
#include
void main(void)
{
FILE *myfile;
char c;
myfile = fopen("firstfile.txt", "r");
if (myfile == NULL) printf("File doesn't exist\n");
else {
do {
c = getc(myfile);
77 | P a g e

putchar(c);

} while (c != EOF);

}
fclose(myfile);

}
USING FILES
• Declare a variable of type FILE
To use files in C programs, you must declare a file variable to use. This variable must be of type FILE, and
be declared as a pointer type.
FILE is a predefined type. You declare a variable of this type as

FILE *in_file;
This declares infile to be a pointer to a file.
• Associate the variable with a file using fopen()
Before using the variable, it is associated with a specific file by using the fopen() function, which accepts
the pathname for the file and the access mode (like reading or writing).

• in_file = fopen( "myfile.dat", "r" );
In this example, the file myfile.dat in the current directory is opened for read access.
• Process the data in the file
Use the appropriate file routines to process the data
• When finished processing the file, close it
Use the fclose() function to close the file.

• fclose( in_file );

The following illustrates the fopen function, and adds testing to see if the file was opened successfully.

#include <stdio.h>
/* declares pointers to an input file, and the fopen function */
FILE *input_file, *fopen ();

/* the pointer of the input file is assigned the value returned


from the fopen call. */
/* fopen tries to open a file called datain for read only. Note
that */
/* "w" = write, and "a" = append. */
input_file = fopen("datain", "r");

/* The pointer is now checked. If the file was opened, it will


point to the first */
/* character of the file. If not, it will contain a NULL or 0.
*/
if( input_file == NULL ) {
78 | P a g e

printf("*** datain could not be opened.\n");


printf("returning to dos.\n");
exit(1);
}

NOTE: Consider the following statement, which combines the opening of the file and its test to see if it was
successfully opened into a single statement.

if(( input_file = fopen ("datain", "r" )) == NULL ) {


printf("*** datain could not be opened.\n");
printf("returning to dos.\n");
exit(1);
}

INPUTTING/OUTPUTTING SINGLE CHARACTERS


Single characters may be read/written with files by use of the two functions, getc(), and putc().

int ch;

ch = getc( input_file ); /* assigns character to ch */

The getc() also returns the value EOF (end of file), so

while( (ch = getc( input_file )) != EOF )


......................

NOTE that the putc/getc are similar to getchar/putchar except that arguments are supplied
specifying the I/O device.

putc('\n', output_file ); /* writes a newline to output file */

CLOSING FILES
When the operations on a file are completed, it is closed before the program terminates. This allows the
operating system to cleanup any resources or buffers associated with the file. The fclose() function is used to
close the file and flush any buffers associated with the file.

fclose( input_file );
fclose( output_file );

COPYING A FILE
The following demonstrates copying one file to another using the functions we have just covered.

#include <stdio.h>

main() /* FCOPY.C */
{
char in_name[25], out_name[25];
79 | P a g e

FILE *in_file, *out_file, *fopen ();


int c;

printf("File to be copied:\n");
scanf("%24s", in_name);
printf("Output filename:\n");
scanf("%24s", out_name);

in_file = fopen ( in_name, "r");

if( in_file == NULL )


printf("Cannot open %s for reading.\n", in_name);
else {
out_file = fopen (out_name, "w");
if( out_file == NULL )
printf("Can't open %s for
writing.\n",out_name);
else {
while( (c = getc( in_file)) != EOF )
putc (c, out_file);
putc (c, out_file); /* copy EOF */
printf("File has been copied.\n");
fclose (out_file);
}
fclose (in_file);
}
}

TESTING FOR THE End Of File TERMINATOR (feof)


This is a built in function incorporated with the stdio.h routines. It returns 1 if the file pointer is at
the end of the file.

if( feof ( input_file ))


printf("Ran out of data.\n");

THE fprintf AND fscanf STATEMENTS


These perform the same function as printf and scanf, but work on files. Consider,

fprintf(output_file, "Now is the time for all..\n");


fscanf(input_file, "%f", &float_value);

THE fgets AND fputs STATEMENTS


These are useful for reading and writing entire lines of data to/from a file. If buffer is a pointer to a character
array and n is the maximum number of characters to be stored, then

fgets (buffer, n, input_file);


will read an entire line of text (max chars = n) into buffer until the newline character or n=max, whichever
occurs first. The function places a NULL character after the last character in the buffer. The function will be
equal to a NULL if no more data exists.
80 | P a g e

fputs (buffer, output_file);


writes the characters in buffer until a NULL is found. The NULL character is not written to the output_file.
NOTE: fgets does not store the newline into the buffer, fputs will append a newline to the line written to the
output file.

Header File in C :
Header file contains different predefined functions, which are required to run the program. All
header files should be included explicitly before main ( ) function.
It allows programmers to seperate functions of a program into reusable code or file. It contains
declarations of variables, subroutines. If we want to declare identifiers in more than one source
code file then we can declare such identifiers in header file. Header file has extension like '*.h'.
The prototypes of library functions are gathered together into various categories and stored in
header files.
E.g. All prototypes of standard input/output functions are stored in header file 'stdio.h' while
console input/output functions are stored in 'conio.h'.
The header files can be defined or declared in two ways as
Method 1 : #include "header_file-name"
Method 2 : #include <header_file-name>
Method 1 is used to link header files in current directory as well as specified directories using
specific path. The path must be upto 127 characters. This is limit of path declaration. Method 2 is
used to link header files in specified directories only.
Standard Header Files :
Followings are the some commonly used header files which plays a vital role in C programming :

Assert.h Ctype.h Math.h

Process.h Stdio.h Stdlib.h

String.h Time.h Graphics.h

HSEB-GRADE XII
2072(2015)
Sub: Computer Science
Group 'A'
1,a) What is looping? Describe 'for' and 'while' loop with appropriate example.
Answer:
'A loop' is a part of code of a program which is executed repeatedly. A loop is used using condition. The repetition is done until condition
becomes condition true. A loop declaration and execution can be done in following ways:
· Check condition to start a loop
· Initialize loop with declaring a variable.
· Executing statements inside loop.
· Increment or decrement of value of a variable.

'For' loop is a programming language control statement for specifying iteration, which allows code to be executed repeatedly until condition
is tru.
In C programming, Syntax:
for(initial value;condition;counter)
{
81 | P a g e

Statement...
}
Step 1,
The initial step is executed first, and only once. This step allows to declare and initialize any loop control variables.
Step 2,
The condition is evaluated. If it is true, the body of the loop is executed. If it is false, Loop is stop.
Step 3,
After the body of the 'for' loop executes, the flow of control jumps back up to the counter. This statement allows to update any loop control
variables. After that it will check the condition.
The condition is true, the loop executes and the process repeats itself, After the condition becomes false, the 'for' loop terminates.
Example:
#include<stdio.h>
void main()
{
Int I;
For(i=1;i<=5;i++)
{
printf(“Condition is true\n”);
}
printf(“program End\n”);
}

‘While loop’ Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop
body. In C programming, Syntax:
while(Condition)
{
Statement...
Counter (increment / decrement)
}
Example:
#include <stdio.h>
int main()
{
int x = 0;
while ( x < 10 )
{
printf( "%d\n", x );
x++;
}
}

1,b) Write a program to check if a given number is odd or even using if statement.
Answer:
#include<stdio.h>
void main()
{
int num;
printf("Input Number:");
scanf("%d",&num);
if(num%2==0)
printf("%d is Even\n",num);
else
printf("%d is Odd\n",num);
}

2) Describe any five string handling function with example.


Answer:

Function Name Description

strlen Returns the length of a string.

strlwr Returns upper case letter to lower case.

strupr Returns lower case letter to upper case.


82 | P a g e

strcmp Compares two strings.

strrev Returns length of a string.

Example:
#include <stdio.h>
#include <string.h>
void main()
{
char str[50];
char *m="abc";
printf("\n\t Enter your name : ");
gets(str);
printf("\nLower case of string: %s",strlwr(str));
printf("\nUpper case of string: %s",strupr(str));
printf("\nReverse of string: %s",strrev(str));
printf("\nLength of String: %d",strlen(str));
printf("\nString compare %d ",strcmp(str,m));
}

3) What is array? Write a program to find addition of two matrices.


Answer:
Array is a collection of homogenous data stored under unique name. The values in an array is called as 'elements of an array.' These
elements are accessed by numbers called as 'subscripts or index numbers.' Arrays may be of any variable type. Array is also called as
'subscripted variable.'
Types of an Array :
1. One / Single Dimensional Array
2. Two Dimensional Array
Single / One Dimensional Array :
The array which is used to represent and store data in a linear form is called as 'single or one dimensional array.'
Two Dimensional Array : The array which is used to represent and store data in a tabular form is called as 'two dimensional array.' Such
type of array specially used to represent data in a matrix form.
Example: addition of two matrices
#include<stdio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
puts("First matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
puts("\nSecond matrix:");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);

for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<3;i++){
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",c[i][j]);
}

4,a)Differentiate between structure and union.


Answer:
Structure is user defined data type which is used to store heterogeneous data under unique name. Keyword 'struct' is used to declare
structure. The variables which are declared inside the structure are called as 'members of structure'.

Union is user defined data type used to stored data under unique variable name at single memory location. Union is similar to that of
structure. Syntax of union is similar to structure.
The major difference between structure and union is 'storage.'
In structures, each member has its own storage location, whereas all the members of union use the same location. Union contains many
members of different types, it can handle only one member at a time.
83 | P a g e

4,b) Write a program to find greatest number among four numbers.


Answer:
#include<stdio.h>
void main()
{
int i,j,gt=0;
int n[4];
for(i=0;i<4;i++)
{
printf("%d, Input Number:",i);
scanf("%d",&n[i]);
}
for(j=0;j<4;j++)
{
if(gt<=n[j])
{
gt=n[j];
}

}
printf("%d\n",gt);
}

5,a) Describe any two file handling functions.


Answer:
fopen()
Creates a new file. Opens an existing file.
fclose
Closes a file which has been opened for use

To use files in C programs, must declare a file variable to use. This variable must be of type FILE, and be declared as a pointer type. FILE
is a predefined type.
Syntax: FILE *file_pointer;
Syntax for 'fopen()' function:
file_pointer=fopen("file name", file handling mode);
'fclose()' function use for closing the opened file.
Example:
#include
void main(void)
{
FILE *fp;
char c;
myfile = fopen("firstfile.txt", "r");
if (fp == NULL)
printf("File doesn't exist\n");
else
{
do {
c = getc(fp);
putchar(c);
} while (c != EOF);
}
fclose(fp);
}
5,b) Write a program to display name, age and address reading from file 'record.dat'.
Answer:
#include "stdio.h"
void main()
{
FILE *f;
char ch;
f=fopen("'record.dat'","r");
while((ch=fgetc(f))!= EOF)
printf("%c",ch);
fclose(f);
}
84 | P a g e

HSEB-GRADE XII
2070(2014)
Computer Science
Candidates are required to give their answer in their own words as far as practicable.

Group ‘A’
Long answer questions
Attempt any four questions
1. Write a program which reads name of 100 students and sort them in alphabetical order.
Answer:
#include<stdio.h>
void main()
{
char nm[100][20];
char tmp[20];
int r=100,i,m,n,j;
for(i=0;i<r;i++)
{
printf("Input Name:");
scanf("%s",&nm[i]);
}
printf("\n\n\nsorting:\n");
for(m=0;m<r;m++)
{
for(n=0;n<r;n++)
{
if(strcmp(nm[n-1],nm[n])>0)
{
strcpy(tmp,nm[n-1]);
strcpy(nm[n-1],nm[n]);
strcpy(nm[n],tmp);
}
}
}
for(j=0;j<r;j++)
{
printf("%s\n",nm[j]);
}
}

1. Describe ‘Sequence’, ‘Selection’ and ‘Loop’ with flowchart. Write a program to check if a number
is odd or even.
Answer:
Sequence: A sequence point defines any point in a computer program's execution at which it is guaranteed
that all effects of previous evaluations will have been performed. They are often mentioned in reference to
C, because the result of some expressions can depend on the order of evaluation of their sub-expressions.
85 | P a g e

Adding one or more sequence points is one method of ensuring a consistent result, because this restricts the
possible orders of evaluation.

Selection: selection also called a decision, one of the three basic logic structures in c programming. The
other two logic structures are sequence and loop. In a selection structure, a question is asked, and depending
on the answer, the program takes one of two courses of action, after which the program moves on to the next
event.
86 | P a g e

Loop: 'A loop' is a part of code of a program which is executed repeatedly. A loop is used using condition.
The repetition is done until condition becomes condition true. A loop declaration and execution can be done
in following ways:
• Check condition to start a loop
• Initialize loop with declaring a variable.
• Executing statements inside loop.
• Increment or decrement of value of a variable.
87 | P a g e

Odd, Even program:


#include<stdio.h>
void main()
{
int num;
printf("Input Number:");
scanf("%d",&num);
if(num%2==0)
printf("%d is Even\n",num);
else
printf("%d is Odd\n",num);
}

2. What is pointer? Describe the benefits of pointer with example.


Answer:
Pointer is a variable which holds the memory address of another address variable. Pointers are represented
by '*'. It is a derive data type in C. Pointer returns the value of stored address.
Benefits of pointers:
• Pointers provide direct access to memory
• Pointers provide a way to return more than one value to the functions
• Reduces the storage space and complexity of the program
• Reduces the execution time of the program
• Provides an alternate way to access array elements
• Pointers can be used to pass information back and forth between the calling function and called
function.
• Pointers allows us to perform dynamic memory allocation and deallocation.
• Pointers helps us to build complex data structures like linked list, stack, queues, trees, graphs etc.
88 | P a g e

• Pointers allows us to resize the dynamically allocated memory block.


• Addresses of objects can be extracted using pointers
Example:
#include <stdio.h>
#include <conio.h>
void main()
{
int a=10;
int *ptr;
clrscr();
ptr = &a;
printf("\n\t Value of a : %d", a);
printf("\n\n\t Address of pointer ptr : %d", ptr);
getch();
}

3. What is an array? Write a program which finds multiplication table of two matrices (3*3).
Answer:
Array is a collection of homogenous data stored under unique name. The values in an array is called as
'elements of an array.' These elements are accessed by numbers called as 'subscripts or index numbers.'
Arrays may be of any variable type. Array is also called as 'subscripted variable.'
Types of an Array :
1. One / Single Dimensional Array
2. Two Dimensional Array
Single / One Dimensional Array :
The array which is used to represent and store data in a linear form is called as 'single or one dimensional
array.'
Two Dimensional Array : The array which is used to represent and store data in a tabular form is called as
'two dimensional array.' Such type of array specially used to represent data in a matrix form.

Program:
#include <stdio.h>
void main()
{
int m[3][3];
int n[3][3];
int mn[3][3];
int i,j,k,l;
int x,y,z,v;
int a,s,q;
int sum=0;
printf("Input 3*3 Matrix A=[]:\n");
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
scanf("%d",&m[j][k]);
}
}
89 | P a g e

printf("Input 3*3 Matrix B=[]:\n");


for(x=0;x<3;x++)
{
for(y=0;y<3;y++)
{
scanf("%d",&n[x][y]);
}
}

printf("Matrix table:\n");
printf("A=");
for(l=0;l<3;l++)
{
for(i=0;i<3;i++)
{
printf("\t%d",m[l][i]);
}
putchar('\n');
}

printf("\n\nB=");
for(l=0;l<3;l++)
{
for(i=0;i<3;i++)
{
printf("\t%d",n[l][i]);
}
putchar('\n');
}
//matrix calculation
for(a=0;a<3;a++)
{
for(s=0;s<3;s++)
{
sum=0;
for(q=0;q<3;q++)
{

sum=sum+(m[a][q]*n[q][s]);
}
mn[a][s]=sum;

}
}

//matrix calculation end here


//display result
printf("Answer:\n");
for(l=0;l<3;l++)
90 | P a g e

{
for(i=0;i<3;i++)
{
printf("\t%d",mn[l][i]);
}
putchar('\n');
}

4. Write a program which reads name, roll number and age from a file named “student.dat” and display
them.
Answer:

#include <stdio.h>
void main()
{
FILE *fp;
char c;
fp=fopen("students.dat","r");
puts("Name roll age");
while((c=fgetc(fp))!=EOF)
{

printf("%c",c);

}
}

Group ‘B’
Short answer questions
Attempt any seven questions:
5. Describe different levels of feasibility study.
Answer:
Different levels of feasibilities are:
• Technical feasibility
• Economic feasibility
• Operational feasibility
• Legal feasibility
Technical Feasibility:
Technical feasibility is concerned with the availability of hardware and software required for the
development of the system, to see compatibility and maturity of the technology proposed to be used and to
see the availability of the required technical manpower to develop the system.

Economic Feasibility:
91 | P a g e

It is the measure of cost effectiveness of the project. The economic feasibility is nothing but judging
whether the possible benefit of solving the problems is worthwhile or not. When the specific requirements
and solutions have been identified, the analyst weighs the cost and benefits of all solutions, this is called
“cost benefit analysis”. A project which is expensive when compared to the savings that can be made from
its usage, then this project may be treated as economically infeasible.

Operational Feasibility:
Operational feasibility is all about problems that may arise during operations.
Information The system needs to provide adequate, timely, accurate and useful information. It should be
able to supply all the useful and required information to all levels and categories of users.
Response time It needs to study the response time of the system in term of throughput. It should be fast
enough to give the required output to the users.
Accuracy A software system must operate accurately. It means that it should provide value to its users.
Accuracy is the degree to which the software performs its required functions and gives desired output
correctly.
Security There should be adequate security to information and data. It should be able to protect itself from
fraud.
Services The system needs to be able to provide desirable and reliable services to its users.
Efficiency The system needs to be able to use maximum of the available resources in an efficient manner so
that there are no delays in execution of jobs.

Legal Feasibility:
Legal feasibility studies issues arising out of the need to the development of the system. The possible
consideration might include copyright law, labor law, antitrust legislation, foreign trade, regulation, etc.
Legal feasibility plays a major role in formulating contracts between vendors and users.

6. Who is system analyst? List out the rolls of system analyst.


Answer:
The work of a systems analyst who designs an information system is the same as an architect of a house.
Three groups of people are involved in developing information systems for organizations. They are
managers, users of the systems and computer programmers who implement systems. The systems analyst
coordinates the efforts of all these groups to effectively develop and operate computer based information
systems. Systems analysts develop information systems. For this task, they must know about concepts of
systems. They must be involved in all the phases of system development life cycle.
It mainly consists of four phases: System Analysis, System Design, System Construction & Implementation
and System Support. Every phase consist of inputs, tasks and outputs.

ROLE OF A SYSTEMS ANALYST


The success of an information system development is based on the role of Systems analyst. Some important
roles are:
Change Agent: The analyst may be viewed as an agent of change. A candidate system is designed to
introduce change and reorientation in how the user organization handles information or makes decisions.
Then, it is important that the user accepts change. For user acceptance, analysts prefer user participations
during design and implementation. Analyst carefully plans, monitors and implements change into the user
domain because people inherently resist changes.
Investigator and Monitor: A systems analyst may investigate the existing system to find the reasons for its
failure.
Architect: The analyst’s role as an architect is liaison between the user’s logical design requirements and the
detailed physical system design.
92 | P a g e

Psychologist: In system development, systems are built around people. The analyst plays the role of
psychologist in the way s/he reaches people, interprets their thoughts, assesses their behavior and draws
conclusions from these interactions. Psychologist plays a major role during the phase of fact finding.
Motivator: System acceptance is achieved through user participation in its development, effective user
training and proper motivation to use the system.
Intermediary: In implementing a candidate system, the analyst tries to appease all parties involved.
Diplomacy in dealing with people can improve acceptance of the system.

7. What is RDBMS? List out the functions of RDBMS.


Answer:
RDBMS stands for Relational Database Management System. RDBMS data is structured in database tables,
fields and records. Each RDBMS table consists of database table rows. Each database table row consists of
one or more database table fields. RDBMS store the data into collection of tables, which might be related by
common fields (database table columns). RDBMS also provide relational operators to manipulate the data
stored into the database tables. Most RDBMS use SQL as database query language.
Functions of RDBMS:
getConnectionStatus()
setCurrentConnection()
unsetConnection()
beginTransaction()
commit()
rollback()
insert()
update()
delete()
queryUsingConceptProps()
queryUsingPreparedStmt()
queryUsingPrimaryKeys()
queryUsingSQL()
assertDBInstance()
executePreparedStmt()
executeSQL()
createQuery()
closeQuery()
getNextPage()
getNextPageFromOffset()
getPreviousPage()
getPreviousPageFromOffset()

8. Describe “Operators” which are used in C-programming.


Answer:
In C programming, an operator is a symbol that tells the compiler to perform specific mathematical or
logical manipulations. C language is rich in built-in operators and provides the following types of operators:
Arithmetic Operators
Operator Description
+ Adds two operands
- Subtracts second operand from the first
93 | P a g e

* Multiplies both operands


/ Divides numerator by de-numerator
% Modulus Operator and remainder of after an integer division
++ Increments operator increases integer value by one
-- Decrements operator decreases integer value by one
Relational Operators
Operator Description
== Checks if the values of two operands are equal or not, if yes then condition becomes true.
Checks if the values of two operands are equal or not, if values are not equal then condition
!=
becomes true.
Checks if the value of left operand is greater than the value of right operand, if yes then
>
condition becomes true.
Checks if the value of left operand is less than the value of right operand, if yes then
<
condition becomes true.
Checks if the value of left operand is greater than or equal to the value of right operand, if
>=
yes then condition becomes true.
Checks if the value of left operand is less than or equal to the value of right operand, if yes
<=
then condition becomes true.
Logical Operators
Operator Description
Called Logical AND operator. If both the operands are non-zero, then condition becomes
&&
true.
Called Logical OR Operator. If any of the two operands is non-zero, then condition
||
becomes true.
Called Logical NOT Operator. Use to reverses the logical state of its operand. If a
!
condition is true then Logical NOT operator will make false.
Bitwise Operators
Operator Description
& Binary AND Operator copies a bit to the result if it exists in both operands.
| Binary OR Operator copies a bit if it exists in either operand.
^ Binary XOR Operator copies the bit if it is set in one operand but not both.
~ Binary Ones Complement Operator is unary and has the effect of 'flipping' bits.
Binary Left Shift Operator. The left operands value is moved left by the number of bits
<<
specified by the right operand.
Binary Right Shift Operator. The left operands value is moved right by the number of bits
>>
specified by the right operand.
Assignment Operators
Operator Description
94 | P a g e

= Simple assignment operator, Assigns values from right side operands to left side operand
Add AND assignment operator, It adds right operand to the left operand and assign the
+=
result to left operand
Subtract AND assignment operator, It subtracts right operand from the left operand and
-=
assign the result to left operand
Multiply AND assignment operator, It multiplies right operand with the left operand and
*=
assign the result to left operand
Divide AND assignment operator, It divides left operand with the right operand and assign
/=
the result to left operand
Modulus AND assignment operator, It takes modulus using two operands and assign the
%=
result to left operand
<<= Left shift AND assignment operator
>>= Right shift AND assignment operator
&= Bitwise AND assignment operator
^= bitwise exclusive OR and assignment operator
|= bitwise inclusive OR and assignment operator
Misc. Operators
Operator Description
sizeof() Returns the size of a variable.
& Returns the address of a variable.
* Pointer to a variable.
?: Conditional Expression

9. What is Network? List out the benefits of Network.


Answer:
A computer network is a set of computers or devices that are connected with each other to carry on data and
share information. In computing, it is called a network as a way to interconnect two or more devices to each
other using cables, signals, waves or other methods with the ultimate goal of transmitting data, share
information, resources and services.
Benefits of Network:
• Helps to enhance connectivity:
• Networking helps in sharing of hardware:
• Eases out management of data.
• Internet
• Data Sharing
• Networking has promoted gaming.

10. Describe the importance of OOP.


Answer:
The importance of OOP:
95 | P a g e

• Simplicity: software objects model real world objects, so the complexity is reduced and the program
structure is very clear;
• Modularity: each object forms a separate entity whose internal workings are decoupled from other
parts of the system;
• Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO
program. Changes inside a class do not affect any other part of a program, since the only public interface
that the external world has to a class is through the use of methods;
• Extensibility: adding new features or responding to changing operating environments can be solved
by introducing a few new objects and modifying some existing ones;
• Maintainability: objects can be maintained separately, making locating and fixing problems easier;
• Re-usability: objects can be reused in different programs.

11. Describe computer crime and its various forms.


Answer:
Computer crime, or Cybercrime, refers to any crime that involves a computer and a network. The computer
may have been used in the commission of a crime, or it may be the target. Net crime refers, more precisely,
to criminal exploitation of the Internet. Physical presence is not essential for the cybercrime to take a place.
The requirements to commit Cyber Crimes are few, compared to the possible repercussions caused and easy
to get as programs and software are available on the Internet. Such crimes generate threats to the nation’s
security and the personal financial health Issues surrounding this type of crime have become high‐profile,
particularly those surrounding cracking, copyright infringement, child pornography, and child grooming.
There are also problems of privacy when confidential information is lost or intercepted, lawfully or
otherwise.
Various forms are:
• Computer viruses
• Denial‐of‐service attacks
• Malware (malicious code)
• Cyber stalking
• Fraud and identity theft
• Information warfare
• Phishing scams

12. What is multimedia? List out the advantages of multimedia.


Answer:
Multimedia:
Multimedia is media and content that uses a combination of different content forms. The term can be used
as a noun (a medium with multiple content forms) or as an adjective describing a medium as having
multiple content forms. Multimedia includes a combination of text, audio, still images, animation, video,
and interactivity content forms.

Advantages of multimedia:
• It is integrated and interactive. All the different mediums are integrated through the digitization
process. Interactivity is heightened by the possibility of easy feedback.
• It is flexible. Being digital, this media can easily be changed to fit different situations and audiences.
• It can be used for a wide variety of audiences, ranging from one person to a whole group.
• Increases learning effectiveness.
• More appealing over traditional, lecture-based learning methods.
• Offers significant potential in improving personal communications, education and training efforts.
• Reduces training costs.
96 | P a g e

• Easy to use.
• Tailors information to the individual.
• Provides high-quality video images & audio.
• Offers system portability.
• Gathers information about the study results of the student.

13. Describe the objectives of e-governance?


Answer:
‘E‐Government' (or Digital Government) is defined as ‘The utilization of the Internet and the world‐wide
web for delivering government information and services to the citizens.’ E‐Governances is digital
interaction between a government and citizens (G2C), government and businesses/commerce/ecommerce
(G2B), and between government agencies (G2G), Government‐to‐Religious Movements/Church (G2R),
Government‐to‐Households (G2H). This digital interaction consists of governance, information and
communication technology (ICT), business process re‐engineering (BPR), and e‐citizen at all levels of
government (city, state/province, national, and international). 'Electronic Government' essentially refers to
the approach ‘How government utilized IT, ICT, and other web‐based telecommunication technologies to
improve and/or enhance on the efficiency and effectiveness of service delivery in the public sector.’
14. Write Short notes on:
a. Cyber law.
Answer:
Legal aspects of computing are related to various areas of law. Cyber law is a term that encapsulates the
legal issues related to use of communicative, transactional, and distributive aspects of networked
information devices and technologies. It is less a distinct field of law than property or contract law, as it is a
domain covering many areas of law and regulation. Some leading topics include intellectual property,
privacy, freedom of expression, and jurisdiction. Information Technology Law (or IT Law) is a set of recent
legal enactments, currently in existence in several countries, which governs the process and dissemination of
information digitally. These legal enactments cover a broad gamut of different aspects relating to computer
software, protection of computer software, access and control of digital information, privacy, security,
internet access and usage, and electronic commerce.

b. Expert System.
Answer:
An expert system is an artificial intelligence application that uses a knowledge base of human expertise to
aid in solving problems. The degree of problem solving is based on the quality of the data and rules obtained
from the human expert. Expert systems are designed to perform at a human expert level. In practice, they
will perform both well below and well above that of an individual expert. The expert system derives its
answers by running the knowledge base through an inference engine, a software program that interacts with
the user and processes the results from the rules and data in the knowledge base. Expert systems are used in
applications such as medical diagnosis, equipment repair, investment analysis, financial, estate and
insurance planning, route scheduling for delivery vehicles, contract bidding, counseling for self-service
customers, production control and training.
97 | P a g e

********************************

HSEB – Grade XII (2013)


(Computer Science)
Solved Questions

Group ‘A’
Long Answer
Q1) What is control statement? Describe ‘Sequence’, ‘Selection’ and ‘Loop’ with flow chart
and example.

Answer:
Control Statement: Control statements enable us to specify the flow of program control; i.e., the
order in which the instructions in a program must be executed. They make it possible to make
decisions, to perform tasks repeatedly or to jump from one section of code to another. The if else
Statement, switch Statement, Loops, while Loop, do while Loop, for Loop, break Statement,
continue Statement and goto Statement are the examples of control statements.
There are four types of control statements in C:
• Decision making statements

• Selection statements

• Iteration statements

• Jump statements
Sequence: A sequence point defines any point in a computer program's execution at which it is
guaranteed that all effects of previous evaluations will have been performed. They are often
mentioned in reference to C, because the result of some expressions can depend on the order of
evaluation of their sub-expressions. Adding one or more sequence points is one method of
ensuring a consistent result, because this restricts the possible orders of evaluation.
98 | P a g e

Selection: selection also called a decision, one of the three basic logic structures in c
programming. The other two logic structures are sequence and loop. In a selection structure, a
question is asked, and depending on the answer, the program takes one of two courses of action,
after which the program moves on to the next event.

Loop: 'A loop' is a part of code of a program which is executed repeatedly. A loop is used using
condition. The repetition is done until condition becomes condition true. A loop declaration and
execution can be done in following ways:
• • Check condition to start a loop
• • Initialize loop with declaring a variable.
• • Executing statements inside loop.
• • Increment or decrement of value of a variable.
99 | P a g e

Q2) Write a program which reads name of 20 employees and sort them in alphabetic order.

Answer:
#include "stdio.h"
#include "string.h"
#include "conio.h"
void main()
{
int i,j;
char name[20][20],temp[20];
for(i=0;i<20;i++)
{
printf("Enter the name of %dth person:\n",i+1);
scanf("%s",&name[i]);
}
printf("\n The names in original order are:\n");
for(i=0;i<20;i++)
{
printf("%d.%s\n",i+1,name[i]);
}
for(i=0;i<20-1;i++)
{
for(j=i+1;j<20;j++)
{
100 | P a g e

if(strcmp(name[i],name[j])>0 )
{
strcpy(temp,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],temp);
}
}
}

printf("\n\nThe names in alphabetical order are:\n");


for(i=0;i<20;i++)
{
printf("%d.%s\n",i+1,name[i]);
}
getch();
}

Q3) Differentiate between structure and union with suitable examples.

Answer:
Structure: Structure is a method of packing the data of different types. When we require using a
collection of different data items of different data types in that situation we can use a structure. A
structure is used as a method of handling a group of related data items of different data types.
Example:
#include "stdio.h"

#include "conio.h"

struct comp_info

char nm[100];

char addr[100];

}info;

void main()

clrscr();

printf("\n Enter Company Name : ");

gets(info.nm);

printf("\n Enter Address : ");


101 | P a g e

gets(info.addr);

printf("\n\n Company Name : %s",info.nm);

printf("\n\n Address : %s",info.addr);

getch();

}
Union: Union is user defined data type used to stored data under unique variable name at single
memory location. Union is similar to that of structure. Syntax of union is similar to structure. But
the major difference between structure and union is 'storage.' In structures, each member has its
own storage location, whereas all the members of union use the same location. Union contains
many members of different types, it can handle only one member at a time. To declare union data
type, 'union' keyword is used. Union holds value for one data type which requires larger storage
among their members.
Example:
#include "stdio.h"

#include "conio.h"

union techno

int id;

char nm[50];

}tch;

void main()

clrscr();

printf("\n\t Enter developer id : ");

scanf("%d", &amp;tch.id);

printf("\n\n\t Enter developer name : ");

scanf("%s", tch.nm);

printf("\n\n Developer ID : %d", tch.id);//Garbage

printf("\n\n Developed By : %s", tch.nm);


102 | P a g e

getch();

Q4) What is recursion? Write a program to calculate factorial value of given number using
recursive function.

Answer:
Recursion is a programming technique that allows the programmer to express operations in terms
of themselves. In C, this takes the form of a function that calls itself. A useful way to think of
recursive functions is to imagine them as a process being performed where one of the instructions
is to "repeat the process". This makes it sound very similar to a loop because it repeats the same
code, and in some ways it is similar to looping. On the other hand, recursion makes it easier to
express ideas in which the result of the recursive call is necessary to complete the task.
Example:
#include "stdio.h"

#include "conio.h"

int fact(int);

void main()

int num,f;

printf("\nEnter a number: ");

scanf("%d",&num);

f=fact(num);

printf("\nFactorial of %d is: %d",num,f);

int fact(int n)

if(n==1)

return 1;

else

return(n*fact(n-1));
103 | P a g e

Q5) Write a program which reads name, department and age from a file named
"Employee.dat" and display them.

Answer:
#include "stdio.h"

#include "conio.h"
void main()
{
FILE *f;
char ch;
f=fopen("employee.txt","r");
while( ( ch = fgetc(f) ) != EOF )
printf("%c",ch);
fclose(f);
getch();
}

Group ‘B’
Short Answer Questions

Q6) What is system? Explain the basic elements of system.


Answer:
A System may be defined as orderly grouping of interdependent components linked together
according to a plan to achieve a specific goal. Each component is a part of total system and it has
to do its own share of work for the system to achieve the desired goal.
Purpose, Boundary, Environment, Inputs, and Outputs are some important terms related to
Systems.
• A System’s purpose is the reason for its existence and the reference point for measuring its
success.
• A System’s boundary defines what is inside the system and what is outside.
• A System Environment is everything pertinent to the System that is outside of its boundaries.
• A System’s Inputs are the physical objects and information that cross the boundary to enter it
from its environment.
• A system’s Outputs are the physical objects and information that go from the system into its
environment.

Q7) Who is system analyst? List out the roles of system analyst.
Answer:
Systems analyst who designs an information system is the same as an architect of a house. Three
groups of people are involved in developing information systems for organizations. They are
managers, users of the systems and computer programmers who implement systems. The
systems analyst coordinates the efforts of all these groups to effectively develop and operate
computer based information systems. Systems analysts develop information systems. For this
104 | P a g e

task, they must know about concepts of systems. They must be involved in all the phases of
system development life cycle. It mainly consists of four phases: System Analysis, System
Design, System Construction &amp; Implementation and System Support. Every phase consist of
inputs, tasks and outputs.
Roles of system analyst:
Change Agent: The analyst may be viewed as an agent of change.
Investigator and Monitor: A systems analyst may investigate the existing system to find the
reasons for its failure.
Architect: The analyst’s role as an architect is liaison between the user’s logical design
requirements and the detailed physical system design.
Psychologist: In system development, systems are built around people.
Motivator: System acceptance is achieved through user participation in its development, effective
user training and proper motivation to use the system.
Intermediary: In implementing a candidate system, the analyst tries to appease all parties
involved.

Q8) Differentiate between DBMS and RDBMS with examples.


Answer:
DBMS
A Database Management System (DBMS) is a set of computer programs that controls the
creation, maintenance, and the use of the database in a computer platform or of an organization
and its end users. A DBMS is a system software package that helps the use of integrated
collection of data records and files known as databases. It allows different user application
programs to easily access the same database. Example: Perl, Python, IMS etc..
RDBMS
A Relational Database Management System (RDBMS) is a Database Management System
(DBMS) that is based on the relational model. RDBMS is a DBMS in which data is stored in the
form of tables and the relationship among the data is also stored in the form of tables. Example:
Microsoft SQL Server, Oracle, Access, DB2 etc..

Q9) Describe the data types which are used in C programming.


Answer:
Followings are the most commonly used data types in C.
105 | P a g e

Q10) Describe the types of network topologies with clear diagram.


Answer:
Network topologies are:
Bus Topology:
In local area networks where bus topology is used, each node is connected to a single cable.
Each computer or server is connected to the single bus cable. A signal from the source travels in
both directions to all machines connected on the bus cable until it finds the intended recipient. If
the machine address does not match the intended address for the data, the machine ignores the
data. Alternatively, if the data does match the machine address, the data is accepted.
106 | P a g e

Star Topology:
Star networks are one of the most common computer network topologies. In its simplest form, a
star network consists of one central switch, hub or computer, which acts as a conduit to transmit
messages.
This consists of a central node, to which all other nodes are connected; this central node provides
a common connection point for all nodes through a hub.

Ring Topology:
A ring network is a network topology in which each node connects to exactly two other nodes,
forming a single continuous pathway for signals through each node - a ring. Data travels from
node to node, with each node along the way handling every packet. Because a ring topology
provides only one pathway between any two nodes, ring networks may be disrupted by the failure
of a single link. A node failure or cable break might isolate every node attached to the ring.
107 | P a g e

Tree Topology:
The type of network topology in which a central 'root' node (the top level of the hierarchy) is
connected to one or more other nodes that are one level lower in the hierarchy (i.e., the second
level) with a point-to-point link between each of the second level nodes and the top level central
'root' node, while each of the second level nodes that are connected to the top level central 'root'
node will also have one or more other nodes that are one level lower in the hierarchy (i.e., the
third level) connected to it, also with a point-to-point link, the top level central 'root' node being the
only node that has no other node above it in the hierarchy (The hierarchy of the tree is
symmetrical.) Each node in the network having a specific fixed number, of nodes connected to it
at the next lower level in the hierarchy, the number, being referred to as the 'branching factor' of
the hierarchical tree. This tree has individual peripheral nodes.

Mesh topology:
Mesh networking (topology) is a type of networking where each node must not only capture and
disseminate its own data, but also serve as a relay for other nodes, that is, it must collaborate to
propagate the data in the network. A mesh network can be designed using a flooding technique or
a routing technique. When using a routing technique, the message is propagated along a path, by
108 | P a g e

hopping from node to node until the destination is reached. To ensure all its paths' availability, a
routing network must allow for continuous connections and reconfiguration around broken or
blocked paths, using self-healing algorithms. A mesh network whose nodes are all connected to
each other is a fully connected network. Mesh networks can be seen as one type of ad hoc
network.

Q11) Explain polymorphism and inheritance with example.


Answer:
Polymorphism:
Polymorphism – means the ability of a single variable of a given type to be used to reference
objects of different types, and automatically call the method that is specific to the type of object the
variable references. In a nutshell, polymorphism is a bottom-up method call. The benefit of
polymorphism is that it is very easy to add new classes of derived objects without breaking the
calling code that uses the polymorphic classes or interfaces.

Inheritance:
Inheritance – is the inclusion of behavior (i.e. methods) and state (i.e. variables) of a base class in
a derived class so that they are accessible in that derived class. The key benefit of Inheritance is
that it provides the formal mechanism for code reuse. Any shared piece of business logic can be
moved from the derived class into the base class as part of refactoring process to improve
maintainability of your code by avoiding code duplication. The existing class is called the super
class and the derived class is called the subclass. Inheritance can also be defined as the process
whereby one object acquires characteristics from one or more other objects the same way
children acquire characteristics from their parents.
Example:
#include "iostream.h"
class vehicle
{
int wheels;
float weight;
public:
void message(void)
109 | P a g e

{
cout<<"Vehicle message, from vehicle, the base class\n";
}
};
class car : public vehicle
{
int passenger_load;
public:
void message(void) // second message()
{
cout<<"Car message, from car, the vehicle derived class\n";
}
};
class truck : public vehicle
{
int passenger_load;
float payload;
public:
int passengers(void)
{
return passenger_load;
}
};
class boat : public vehicle
{
int passenger_load;
public:
int passengers(void) {return passenger_load;}
void message(void) // third message()
{
cout<<"Boat message, from boat, the vehicle derived class\n";
}
};
int main()
{
vehicle unicycle;
car sedan_car;
truck trailer;
boat sailboat;
unicycle.message();
sedan_car.message();
trailer.message();
sailboat.message();
// base and derived object assignment
unicycle = sedan_car;
unicycle.message();
return 0;
}
110 | P a g e

Q12) Describe computer crime and its various forms.


Answer:
Computer crimes:
Computer crime, or Cyber crime, refers to any crime that involves a computer and a network. The
computer may have been used in the commission of a crime, or it may be the target. Net crime
refers, more precisely, to criminal exploitation of the Internet. Physical presence is not essential
for the cyber-crime to take a place. The requirements to commit Cyber Crimes are few, compared
to the possible repercussions caused and easy to get as programs and software are available on
the Internet. Such crimes generate threats to the nation’s security and the personal financial
health Issues surrounding this type of crime have become high‐profile, particularly those
surrounding cracking, copyright infringement, child pornography, and child grooming. There are
also problems of privacy when confidential information is lost or intercepted, lawfully or otherwise.
Forms of Cyber Crime
• Cyber Crime has various forms which may include
• hacking (illegal intrusion into a computer system without the permission of owner),
• phishing (pulling out the confidential information from the bank or financial institutional
account holders by deceptive means),
• spoofing (getting one computer on a network to pretend to have the identity of another
computer in order to gain access to the network),
• cyber stalking (following the victim by sending e-mails or entering the chat rooms
frequently),
• cyber defamation (sending e-mails to all concerned or posting on websites, the text
containing defamatory matters about the victim),
• threatening (sending threatening e-mails to victim),
• salami attacks (making insignificant changes which go unnoticed by the victim),
• net extortion,
• pornography (transmitting lascivious material),
• software piracy (illegal copying of the genuine software), email bombing,
• virus dissemination (sending malicious software which attaches itself to other
software),
• IPR theft, identity theft, data theft, etc.

Q13) List out the advantages and disadvantages of multimedia.


Answer:
Advantages of multimedia:
• Increases learning effectiveness.
• Is more appealing over traditional, lecture-based learning methods.
• Offers significant potential in improving personal communications, education and training
efforts.
• Reduces training costs.
• Is easy to use.
• Tailors information to the individual.
• Provides high-quality video images &amp; audio.
• Offers system portability.
111 | P a g e

• Frees the teacher from routine tasks.


• Gathers information about the study results of the student.

Disadvantages of multimedia:
• Expensive
• Not always easy to configure
• Requires special hardware
• Not always compatible

Q14) What are the objectives of e-governance? Explain.


Answer:
E-Governance implies technology driven governance. E-Governance is the application of
Information and Communication Technology (ICT) for delivering government services, exchange
of information communication transactions, integration of various stand-alone systems and
services between Government-to-Citizens, Government-to-Business, Government-to-Government
as well as back office processes and interactions within the entire government frame work.
Through the e-Governance, the government services will be made available to the citizens in a
convenient, efficient and transparent manner. The three main target groups that can be
distinguished in governance concepts are Government, citizens and businesses/interest groups.
In e-Governance there are no distinct boundaries. Generally four basic models are available:
Government to Customer (Citizen), Government to Employees, Government to Government and
Government to Business.

Q15) Write short notes on:


a) Normalization
Answer:
Database normalization is the process of organizing the fields and tables of a relational database
to minimize redundancy and dependency. Normalization usually involves dividing large tables into
smaller (and less redundant) tables and defining relationships between them. The objective is to
isolate data so that additions, deletions, and modifications of a field can be made in just one table
and then propagated through the rest of the database using the defined relationships.
b) Expert system
Answer:
In artificial intelligence, an expert system is a computer system that emulates the decision-making
ability of a human expert. Expert systems are designed to solve complex problems by reasoning
about knowledge, like an expert, and not by following the procedure of a developer as is the case
in conventional programming. An expert system has a unique structure, different from traditional
computer programming. It is divided into two parts, one fixed, independent of the expert system:
the inference engine, and one variable: the knowledge base. To run an expert system, the engine
reasons about the knowledge base like a human.

You might also like