0% found this document useful (0 votes)
47 views

Computer 12 Class Notes (Short)

Uploaded by

Nb Kashif
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)
47 views

Computer 12 Class Notes (Short)

Uploaded by

Nb Kashif
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/ 49

[Ch # i ] Data Basics 23 Computer Science Part-1 ]


SHORT QUESTION 3 a
Ql * What is data?
Ans . Raw facts and figures are called data. It is used to perform certain operation in an
organization. It gives the status of past activities . Data may be numerical like
inventory figures, test scores etc. Data may be non -numerical like your name and
address.
Q 2. What is Information ?
Ans . Processed data is called Information , It is usually output of a process and is
meaningful . The grade of a student in a particular subject in a semester precisely
gives the complete information of the performance of a student ,

Q3. What is the difference between data and information ?


Ans * Data is raw facts where as information is processed form of data Data is given to
*

the computer for input and information is received from the computer in the form
of output ,

Q4. Define data processing and data manipulation *

Ans * Data processing is a computer process that converts data into information or
knowledge The processing is usually assumed to be automated and running on a
*

computer It can also be defined; the manipulation of data to achieve some


required objectives is called data processing.
Applying different operations on data is called data manipulation . These
operations include classification calculation soiling and summarizing
* *
,

05 * Name the four major components of database system


Ans * Data
Raw facts that becomes information after processing
* Hardware
The physical components of a system it includes
o I/O Devices
o Primary Storage
o Secondary Storage Devices
o I/O Channels
O Processor
* Software
All kind of programs which include
o User /System Software
[Ch # i ] Data Basics 24 Computer Science Part-1 ]
o Utilities
• Personnel
People who involves with the system
o Programmer / Analyst
o find Users
o Database Administrator
Q6* Define field *
Ans . Each column of a table in relational database is called a field . It represents the
attributes of the entity . In table it is represented as a column header.
Q 7. Define record.
Ans . A collection of related fields treated as a single unit is called a record Tf we ,

collect different attributes of a student then it will be called student ' s record .
Q 8. Define file *

Ans * A collection of related records treated as a single unit is called a file . If we collect
the record of students then collectively it will be called a student file.
Q9 * Name the file types from usage point of view .
Ans . 1 , Master file
2. Transaction file
3 , Backup file *

Q 10 , Name the tile types from function point of view .


Ans . 1 * Program files
2. Data files.
Q l l . What is program file?
Ans . A file that contains software instruction . The source files and executable files are
examples of program file .
Q 12. What do you mean by file organization ?
Ans . The physical arrangement of records of a file on secondary storage devices is
called file organization . There are a lot of methods to store files on secondary
storage. All the methods have their owrn advantages and disadvantages . The
different type of file organizations arc.
1. Sequential files
2. Direct or random access files
3. Indexed sequential files.
Q 13. Name different types of tile organization?
Ans * 1 . Sequential files
2. Direct or random access files
[Ch # i ] Data Basics Computer Science Part-1 ]
3. Indexed sequential files.
Q 14. What are sequential files?
Ans. In sequential files iceords arc stored sequentially , These file store data as it arrives
one after another in the sequence. These tiles take more time to store data. The
best reason for using sequential files is their degree of portability to other
programs. The drawback to sequential tiles is that you only have sequential
access to your data.
Q 15. What are direct or random access files?
Ans . In random files records are accessed directly without going through the preceding
records. Record in this type of file is stored on a calculated address. In random
files the data is stored exactly as it appears in memory, thus saving processing
time.
Qlti . What are indexed sequential files?
Ans . The data in this type of file can be accessed sequentially as well as randomly
based on a key value. As records are stored in the form of key- pointer pair in the
index file, therefore, it requires more space on the disk as compare to random
files. Its processing is as fast as random files.
Q 17. What is an index?
Ans . A database index is a data structure that improves ( he speed of operations on a
database table . It is a table created by system developer or DBA containing the
key attributes of the table for which the index is created. Indices can be created
using one or more columns of a database table, providing the basis for both rapid
random lookups and efficient access of ordered records.
Q 18. Define database?
Ans . A database is a structured collection of records or data that is stored in a computer
so that a program can consult it to answer queries . The records retrieved in answer
to queries become information that can be used to make decisions. The term
database refers to the collection of related records or related data sets or files, and
the software which is used to manipulate the database is database management
system or DBMS.
Q 19. What is database management system ?
Ans . A collection of programs that enables you to store, modify, and extract
information from a database. There are many different types of DBMS , ranging
from small systems that run on personal computers to huge systems that run on
mainframes. The DBMS is used for large and medium sized organizations having
different types of files for different purposes ,

Q 20. What do you mean by consistency constraint?


[Ch # i ] Data Basics Computer Science Part-1 ]
Ans . These are the rules that must be followed to enter data in the database e .g in name
,

field there must not be a numeric value, in date of birth field there must be a date.
Q 21 , What is data dictionary?
Ans . DBMS uses a file to store the data definition or description of the structure of
database is called data dictionary i e data about database . It holds the name type,
, , ,

range of values, source, and authorization for access for each data clement in the
organization 's files and databases.
Q 22. What is meant by data independence?
Ans . Data independence means that data and application programs are separate from
each other. Physical Implementation of data is hidden from application programs ,
DBMS lies between the application program and database.
Q 23. Name some large databases developed ,
Ans . NADRA , Google, VISA and Amazon books database arc a few commonly know
large databases around the world ,

Q . 24 Write down any two disadvantages of Database System.


Ans . Additional training is required .
Additional Hardware cost
Additional software cost.
Q . 25 What are the activities performed on data?
Ans . The user of database normally has the following facilities.
* Adding new files to the database
* Removing existing files from the database
* Inserting new data into the existing files
* Retrieving data from existing files
* Updating data in existing tiles
* Deleting data from existing files
[Ch # 2] Basic Concepts and Terminology 47 Computer Science Part-1]

Ql . Define relation.
Ans . In relational database the table in which data is stored is also called a relation .
Collection of rows and columns is called table. Each intersection of a row and
column is called a cell . Table contains the descriptive information about an entity .
Table is also called relation . Each tile in a tile management system corresponds to
a table in database management system.
Q 2. What is and Entity?
A ns. Anything about which wc want to store data is called an entity . It can be a person,
place, event etc . Entity always has a unique name with in a domain .
Q3. What is the use of views?
An $ t Views are virtual tables used to keep the data safe and secure from unauthorized
access. Unlike ordinary tables { base tables ) in a relational database a view is not
,

part of the physical schema. It is a dynamic, virtual table computed from data in
the database. Changing the data in a tabic alters the data shown in the view.
Q4. What is a key?
Ans , A key field is a field or set of fields of a database ( typically a relational database )
table which together form a unique identifier for a database record ( a table entry ) ,
The aggregate of these fields is usually referred to simply as nthe key ' \ A Key
field also defines searches.
Q 5. Define Primary key .
Ans . In a relation the attribute or a combination of attributes that uniquely identifies a
row or a record e. g. A Social Security number (associated with a specific person ),
ISBN ( associated with a specific book ) student roll number (associated with only
one student in a class) .
Q 6. Define Secondary key .
Ans . Secondary key is a non -unique field . Some times records are required to be accessed
by a field other than the primary key. In these situations another key that is used is
called secondary key or alternate key,
Q 7. Define Candidate key .
Ans , There can be more than one keys or key combinations that qualify to be selected
as primary key , In a relation there can be only one primary key at a time, Rest of
the keys or key combinations are called candidate keys .
Q 8. Define Composite key .
Ans . Composite key consists of two or more than two fields , Composite key is also
designated as a primary key. It is created in a situation when no single field
fulfills the property of uniqueness. To make it unique more than one field are
combined and used as primary key ,
[Ch # 2] Basic Concepts and Terminology 4s Computer Science Part-1 ]
Q9. Define Sort key.
Ans. A field or a set of fields in a record that dictate the sequence of the file according
to our requirement . For example the sort keys STATE and NAME arrange the
table data alphabetically by name within state , STATE is the major sort key, and
NAME is the minor sort key.
Q 10 , What is the use of index file?
Ans. Indexes are stored in index file. DBMS uses index files to speed up the sorting
and searching operations ,
Q 11 . Who is end user ?
Ans * It is the person who uses the database management system for his need. He must
have knowledge of information technology. He doesn 't need to have the detail
knowledge of the computer system. He should be aware of the usage details of the
software he intends to use.
Q 12. Who is data administrator?
Ans. The DA department is responsible for the definition , organization, supervision,
and protection of data in order to provide good quality shareable, and accessible
,

data throughout the enterprise. The DA establishes and implements policies and
procedures. The Data Administrator manages a staff that is responsible for
establishing and implementing the Data Administration Program.
Q 13. Who is data base administrator?
Ans * A database administrator ( DBA ) is a person who is responsible for the
environmental aspects of a database . In general these include :
,

* Recoverability - Creating and testing Backups


* Integrity - Verifying or helping to verify data integrity
* Security - Defining and /or implementing access controls to the data
* Availability - Ensuring maximum uptime
* Performance - Ensuring maximum performance given budgetary constraints
* Development and testing support - Helping programmers and engineers to efficiently
utilize the database.
Q . 14 List two properties of a relation.
Ans. It has unique column names.
The order of column is insignificant
The order of row is insignificant
Q . 15 Discuss the data manipulation in DBMS system ?
Ans. Data manipulation of database management system is different from file
management system. In database management system
* Data is stored in relations or tables
* A database may have more than one relation with unique names.
* Relations in a database relate to each other using primary and foreign keys .
* DBMS uses index to quickly access the data stored in relations.
[Ch # 2] Basic Concepts and Terminology 49 Computer Science Part-1]

* Database query language i e , SQL is used for data manipulation in database .


+
[ Ch #3] Database Design Process 70 Computer Science Part-11

SHORT QUESTIONS
Q l* Define analysis.
Ans * A process of studying the existing system is known as analysis. The analysis also
determines what should take place in the new system . It is very important activity
for the development of database system . The person responsible for the
requirements analysis is often called” Analyst ’.
1

Q 2. What is the importance of project planning?


A ns. Project planning is part of project management . Initially the project scope is
defined and the appropriate methods for completing the project are determined.
Following this step, the durations for the various tasks necessary to complete the
work are listed and grouped into a work breakdown structure. Then the necessary
resources can be estimated and costs for each activity can be allocated to each
wT

resource giving the total project cost .


,

Q3. What is data modeling?


Ans . The identification of data objects and their relationships to other data objects.
Data modeling is often the first step in database design . Designers first create a
conceptual model of how data items relate to each other. Data modeling involves
a progression from conceptual model to logical model and then to physical
schema.
Q4. Define Cardinality.
Ans . The number of entity occurrences of first entity associated with one or more
occurrence of the second entity is known as cardinality. It is expressed as one or
many e.g. a country can have many cities but a country can have only one capital .
Q 5. Define Modality *
Ans * Modality defines whether the participation of an entity in a relationship is
mandatory or optional . If a relationship has cardinality of zero, it is an optional
relationship. If relationship has at least one cardinality then the relationship is
mandatory .
Q 6. What is an E-R Diagram ?
Ans . An entity-relationship ( ER ) diagram is a specialized graphic that illustrates the
interrelationships between entities in a database . ER diagrams often use symbols
to represent three different types of information .
Q7 * What is logical database design ?
[ Ch #3] Database Design Process Computer Science Part 11-
Ans * It is a process of mapping the conceptual model to the structures of target DBMS ,

If the target database is relational then it will be mapped on normalized relations.


Q 8, What is physical database design ?
Ans. Physical database design is the last stage of database design . The objective of
physical database design is to implement the database as a set of stored , records,
files, indexes and other data structures. These data structures provide performance
and also ensure data integrity, security and recoverability .
Q .9 What is meant by centralized database distribution?
Ans. In centralized database all the data is stored at single location It is easy but have a
*

few disadvantages . Data communications may be high in some cases. Data are not
readily accessible by remote users, If central location fails, whole database fails *

Q. 1 U What is Partitioned database distribution .?


Ans * In partition distribution data is divided into fragments and these fragments are
,

placed at different computers It is more accessible than centralized database


*

strategy .
Q 11
* What is Replicated database distribution *?
Ans . Full copy of database is stored on more than one computer. Any change in parent
computer is replicated to the others. In this strategy more storage space is
required There can be a huge communication cost while replication Frequent
* *

synchronization is also required


[Cfi#4] Data Integrity & Nomializatiort
*9 -
Computer Science Part 11

SHORT QUESTIONS

Ql . What is meant by entity integrity ?


A ns . It is a constraint on entity. Fntity integrity is an integrity rule which states that
every table must have a primary key and that the column or columns chosen to be
the primary key should be unique and not null A direct consequence of this
,

integrity rule is that duplicate rows are forbidden in a table. If each value of a
primary key must be unique no duplicate rows can logically appear in a table . The
NOT NULL characteristic of a primary key ensures that a value can be used to
identify all rows in a table ,

Q 2. What is referential integrity?


Ans . It is a constraint on foreign key. If a foreign key exists in a relation then either the
foreign key value must match the primary key value of some tuple in its parent
table or the foreign key value must be completely NULL.
Q3. What is meant by redundancy?
Ans . Redundancy appears when the same data values are stored more than once in a table.
It is also called redundancy if the same values are stored in more than one table ,

Q4. What is normalization?


Ans . Normalization is a process of converting complex data structures into simple and
stable data structures. It is a technique for reviewing the list of entities and their
attributes to ensure that attributes are stored from where they belong. In other
words wc can say that it is a process of analyzing the dependencies of attributes
within entities ,

Q 5. What is a repeating group ?


Ans . Repealing group is a set of one or more data items that may occur a variable
number of times in a tuple ,

Q 6. What are database anomalies ?


Ans . These are certain situations created when one or more records are deleted ,
modified or inserted in the database and the databases goes into an inconsistent
state.
Q 7. What is insertion anomaly?
Ans . Insertion anomaly occurs w- hen a new record is inserted in the relation . In this
anomaly user cannot insert a fact about an entity until he has an additional fact
about another entity.
Q 8. What is deletion anomaly?
Ans . The deletion anomaly occurs when a record is deleted . In this anomaly the
deletion of a record automatically deletes the fact of another entity.
[Cfi#4] Data Integrity & Nomializatiort 90 -
Computer Science Part 11
Q9. What is modification anomaly?
w

Ans . The modification anomaly occurs when the record is updated in the relation . In
this case the modification in the value of specific attribute requires modification
in all records in which that value occurs.

Q 10, What is partial dependency?


Ans . A type of dependency in which one or more non - key attributes are functionally
dependent on a part of primary key ,

Q 11 . What is transitive dependency?


Ans. The transitive dependency is a type of functional dependency between two or
more non - key attributes. It exists if a non-key attribute depends on any other non -
key attribute,
Q . 12 What is integrity constraint?
Ans . Integrity means the correctness and consistency of the data . Integrity is usually
expressed in terms of certain constraints which are the consistency rules that the
database is not permitted to violate. Integrity is also concerned with the quality of
data. Integrity is maintained with the help of integrity constraints. These
constrains are the rules that are designed to keep data consistent and correct .
Q . 13 What is 1st NF?
Ans . A relation is in first normal form if and only if all underlying domain contain
atomic values only. Each cell should contain only one value and relation does not
contain any repeating group .
Q. 14 What is 2 nd NF?
A relation is in 5nd NF if it is in 1 SI NF and every non- key attribute is fully
functionally dependent on the primary key. All non key attributes must depend on
primary key .
Following arc a tow conditions for 2nd NF ,

* The primary key consists of only one attribute


* No non-key attributes exist in the relation.
* Every non- key attribute is functionally dependant on the primary key.
Q. 15 Whal is 3rd NF?
Ans. A relation is in 3 NF if it is in 2nd NF and no transitive dependencies exist .
Transitive dependency is a functional dependency between two or more non- key
attributes of a relation.
[Ch#;>J ) introduction ajTvlicroso/1 Access 105 Computer Science Part-11

SHORT QUESTIONS

Ql . What is MS-Access ?
Ans . Jt is one of the most popular and powerful DBMS. It provides the features to the
users to create and maintain databases We can create tables, forms, queries and
*

reports using Ms-Access .


Q 2. What is a wizard?
Ans * A Wizard is a helper application that makes performing complex tasks easier . A
Wizard has a simple decision in a window , which has Back and Next buttons
underneath. When you have filled in the required data, you click the Next button
to go to the next window, or you can dick the Back builon to change your
previous decision ,

Q3 * What is menu bar?


Ans . Jt is the second bar from top . It consists of many u’ ords. Each w'ord on this bar
represents a menu. Every word on this bar also has a character underlined. This
underlined character represents the short cut key combination for that particular
menu.
Q4 * What is a database object?
Ans . A component of database system is known as the database object . These database
objects arc used to manage data . The four major database objects are as follows ,

Q 5. What is a Table?
Ans . Table is a collection of row s and columns. All the intersection points of rows and
columns arc called cells . In these cells data can be stored. Each column of table
represents a field. Each field is specified to store a particular type of data . Table
can be viewed in different w^ays but most commonly arc datasheet viewT and
design view ,

Q 6- What is a Query?
Ans . Query is a database object used to get data from the database. In query we can
specify a certain criteria to get the required data. The actual objective of data
storage is that it can be retrieved when ever it is required . Using query object data
can also be deleted and updated .
[Ch#;>J ) introduction ojAtkrosof Access ro6 -
Computer Science Part 11
Q7. What is a form?
Ans. The window that is used to enter data into the database is called form . Using form
data can be entered , edited and even viewed in Microsoft Access - Data entered in
forms directly goes to the tables. Forms are always made after table creation. The
fields on form are linked to the table fields
*

Qfh What are reports?


Ans. Report is a database object used to represent queried data in a presentable format.
Not all but most of the RDBMS provide this facility to their users. Reports can be
generated on the basis of tables and queries. We can apply formatting on the
report to make them more presentable and understandable ,

Q9. What is an IDE?


Ans . IDE stands for integrated development environment . It is a simple and easy way
to do a task It presents graphical objects like button , icons and menus to perform
*

certain operations . Using IDE a new user and programmer can easily do their
jobs MS- Access also provides the same facility for its users
* *
[ Ch # GJ1 Table and Queiy 5°
] Computer Science Part-11

SHORT QUESTIONS
Ql * What is a table?
Ans . Table is a collection of rows and columns. Each intersection of row and column is
called a cell. Cell is the place where data is placed . Table is the fundamental
object of relational database. Table is also known as relation . Each row represents
a tuple and each column represents an attribute of an entity. Table or relation
itself represents an entity.
Q 2* What is meant by degree of a relation?
Ans . The number of fields of a relation is called the degree of that relation . A table’ s
degree is specified at the time of its creation . But as a rule it can be changed at
any time. Change in degree of a table may cause data loss.
Q3* What is meant by the cardinality of the relation ?
Ans . The number of records in a tabic is called the cardinality of that tabic. Cardinality
of a tabic changes as new records are added or previous records are deleted . For
example a table having 40 rows/records has cardinality 40.
Q4* What are two table views available in Microsoft Access?
Ans . Design view and Datasheet view.
Q 5, What is Text data type?
Ans . It is the default data type of a field in Ms -Access . It can contain text or
combinations of text and numbers as well as numbers that don't require
,

calculations, such as phone numbers. Its size is 255 characters or the length set by
the FieldSize property, whichever is less . Microsoft Access does not reserve space
for unused portions of a text field
Q 6. What is Memo data type?
Ans . A text type field that can contain more than 64000 characters. It is used for long
descriptions .
Q 7. What is Number data type?
Ans . This field is used to store numeric data for mathematical calculations. Size of this
data type can be 1 ? 2, 4, or 8 bytes {16 bytes if the FieldSize property is set to
Replication ID ).
Q 8. What is Autonumber data type ?
Ans . A unique sequential (incremented by 1) number or random number assigned by
Microsoft Access whenever a new record is added to a table. AutoNumber fields
can 't be updated. Its size is 4 bytes .
[ Ch # GJ1 Table and Queiy -
Computer Science Part 11
Q 9. What is the use of Default value?
Ans . In some cases the value of all records in a certain field is same. A default value
,

can be set in this case. The user does not need to type the same value again and
again . The property set the default value is used to set default value for a field
Qlfl . What is Sorting?
Ans . Arrangement of data in a particular sequence is called sorting . This sequence can
be in ascending or descending order .
Qll , What is referential integrity ?
Ans . Referential integrity is a system of rules that ensure that relationships between
records in related tables are valid and that you don ' t accidentally delete or change
related data . To enforce referential integrity both tables must have at least one
common field, which have same data type and size.
Q 12* What is a query ?
Ans. A query is a question that requires some data from the database A query is
created by specifying fields to display their from a tabic or another query. It can
also specify condition for extracting data . Queries select records from one or more
tables in a database.
Q 13. What is a join?
Ans . A query that extracts data from multiple tables is called join . It uses the
relationship of tables to get data .
Q 14. What are wildcards ?
Ans . Wildcard is a special symbol that is used in queries to search data . Some
important wild cards are *, ? and #. Wildcard characters are meant to be used
with fields that have the Text data type . You can sometimes use them successfully
with other data types, such as dates .
Q 15. Define criteria in a query ?
Ans . A condition used to limit the number of rows extracted from database is ealled
criteria . For example. Instead of viewing all the suppliers that your company uses,
you can view just suppliers from Japan . To do this, you specify criteria that limits
the results to records whose Country field is "Japan 11 .
[Ch #7] Microsoft Acoess forms & Reports T92 -
Computer Science Part 11

SHORT QUESTIONS

Q. l What is a form?
Ans . A window that consists of visual components for input and display data is called
form. A form is constructed from a collection of individual design elements.
These elements are called controls. The common elements are text boxes, labels,
check boxes etc . these elements arc used for different purposes ,
Q.2 Write a few uses of Form?
Ans . Form is used to add data in the database . It is used to delete data from the
database. Using form data can be modified in the database , Data can be viewed
using forms . Data can also be searched with the help of forms . Forms are also
used as a custom dialog box that accepts user input and carries out an action based
on the input .
Q.3 What is a sub form?
Ans . The sub form is a form that is placed in a parent form. The parent form is called
the main form. Sub form is also called child form. It is useful for the tables w'hen
they have relationship of one to many. The table having foreign key is used for
subform
Q.4 What is conditional formatting?
Ans . The conditional formatting is a special type of formatting. This formatting
depends on the control 's value and can be added to text boxes, lists and combo
boxes .
Q .5 What is a report?
Ans . Reports are the output of database application. The user can generate different
types of reports by manipulating the database.
Q .6 What is linking?
Ans. The process of linking in MS- Access creates a link to an object in another
database table. In this method table is not copied from its original location but just
linked.
Q .7 What is a switch hoard?
Ans . A switchboard is essentially a Microsoft Access form that allows you to facilitate
navigation or perform tasks within your database application. This form is basically a
customized menu that contains user-defined commands; using either buttons, labels,
images or hyperlinks, that invoke actions that will automatically carry out tasks for
you such as opening other forms, running queries or printing reports.
[Ch #7] Microsoft Acoess forms & Reports T93 -
Computer Science Part 11
Q.8 What is keyboard shortcuts?
A ns * Keyboard shortcuts are the combination of keys that are used toperform different
tasks. They can save time and effort .
Q .9 What is input mask ?
Ans. An input mask controls the value of a cell to store it into a specific format c. g. a
database required to store a date field in a dd/ tnm / yy format Jt will be represented
,

with mask / / ,

Q . 10 Define tabular form briefly?


Ans . Jn tabular forms multiple records are displayed with fields in columns and records
in rows. Each row represents a record . It is best for the situation when you want to
display a few' records and of narrow fields and you want to see several records at
the same time ,

Q . ll Define columnar form?


Ans. Form field and label are displayed side by side in columnar form . In this type of
form only one value is displayed at a time. Columnar form provides a record
navigation bar to traverse through records
Q . 12 Define Datasheet form?
Ans * A datasheet form displays data in datasheet view. Each row displays one record at
a time , Datasheet form provides record navigation bar to navigate through
different records. This type of form is often used for the basis of sub form ,

Q . 13 What is a list box?


Ans * It is a type of text box. Multiple values can be associated with list box and more
than one value can be displayed and selected at the same time ,

Q . 14 What is a Combo Box ?


Ans * It is a type of text box , Multiple values can be associated with combo box but
only one value can be displayed and selected at a time ,

Q . 15 What is a switch board?


Ans. It is a type of form used to display buttons linked to different database objects *

These buttons are used to open , close or modify those objects ,


[ Ch # 8] Getting Started v^ ith C 209 -
Computer Science Part 11

SHORT QUESTIONS
Q. l Define Computer.
Ans . Computer is an electronic device that accepts data process it and produce information
according to the instructions given to it .
Q.2 Define Data *
Ans * The collection of raw facts and figures is called data ,
Q .3 Define Information .
Ans . The organized and meaningful form of data after processing is called information .
Q.4 Define Program / Software.
Ans * A set of instructions given to the computer to solve any problem is called a
program , A program is written in a computer language.
Q .5 Define programming Language
Ans * It is the way of communication between user and computer. All the programs are
written in computer language.
Q6 * Define High level language
Ans . It is closed to human language. User can learn and understand high - level language
easily . The instructions of HLL are written in English statements. The programs
of HLL are not directly executed on the computer. A language translator is
required to translate the HLL into low level language ,

Q .7 What is low -level language?


Ans . The language which is close to machine language is called low level language . A
Computer can easily understand low level language, The low level language
requires a deep understanding of the machine architecture.
Q .8 What is machine language ?
Ans . It is the native language of computer. Every machine language instruction consists
of (Ts and Us . It is difficult for human beings to understand and learn it . And it is
also difficult to locate and remove errors in the program . It is directly executed by
the computer. The machine language programs are machine dependent ,
Q .9 What is assembly language?

-^
Ans . Machine language instructions s and Ts ) are replaced with English like words
1

known as mnemonics ( Ne monics ) It is also called symbolic language. An


assembler is required to translate the assembly language programs into machine
language
Q . l ft What is meant by portability?
Ans . The programs written in High level language arc dosed to human language and
programs are machine independent i e a program can be run on different types of
, ,

computers *
[ Ch # 8] Getting Started v^ ith C 210 -
Computer Science Part 11
Q . 11 Define source code.
Ans. The program written in High Level Language is called source program . The
computer docs not understand the source code. The source code is con veiled into
machine code and then it is directly executed on the computer.
Q . 12 What is Object Program?
Ans . The program in a machine language is called object program . The computer
understands the object code directly.
Q . 13 What is Linker?
Ans . The linker is a program that combines the object program with additional library
files and produces one executable file with exe extension. Linking is a process in
,

which the object file is produced by the compiler is linked to many other files by
the linker .
Q . 14 What is Loader?
Ans . For execution , the loader loads the executable files in the memory . It is also
system software Ctrl +F9 key is used to load and run the programs. The
,

executable file ( .exe) runs directly on the computer after loading process .
Q . 15 What is a Language Processor/Translator?
Ans . It is software that is used to translate the high - level language programs into
machine language . Each language has its own translator. Only one type of
translator is used in any language. There are three types of language processor.
Compiler, Interpreter and Assembler
Q . 16 What is a Compiler?
Ans. The language translator translates the source code into object code and the whole
program is translated at the same time . If a program contains errors then compiler
cannot convert the source code into machine code until all the errors are removed
from the source program .
Q . 17 What is an Interpreter?
Ans . The language translator translates the source code into object code statement by
statement . The working of interpreter is slower than the compiler . Any error in the
program stops execution and all the instructions are executed in a program before
errors in the program .
Q . 18 What is an Assembler?
Ans. The language translator translates the assembly language into machine code.
Q . 19 What are POG RAM MING ERRORS ?
Ans . The errors in a program are called BUGS. The process of finding and removing
these errors is called debugging. There arc three typos of errors.
Syntax Errors
Run Time Errors
Logical Errors ,
[ Ch # 8] Getting Started v^ ith C 211 -
Computer Science Part 11
Q . 20 What are Syntax Errors?
Ans . A syntax error occurs when the program violates one or more grammar rules of
high -level language A compiler detects these errors at the time of compilation .
,

The errors must be removed for the successful compilation, These errors arc easy
to locate and remove because the compiler specifies the location and type of error.
Q . 21 What arc Run Time Errors?
Ans * A run time error occurs when the program directs the computer to perform an
illegal operation. Run time errors are detected and displayed by the computer
during the execution of a program. When a run time error occurs, the computer
stops the execution and displays a diagnostic message. Examples: Dividing
number by zero ,

Q . 22 What are Logical Errors?


Ans * A logical error occurs when a program follows a faulty algorithm The compiler*

cannot detect logical errors; therefore no error message is reported from the
compiler Programs cannot be crashed due to logical errors . It is difficult to detect
*

logical error Program with logical errors produces wrong output


* *

Q . 23 Define Preprocessor Directives.


Ans . The instructions given to the compiler before the beginning of the actual program
are called preprocessor directives It always begins with # symbol e g. # include ?
*

#define *

Q . 24 What is #include directive :


Ans * It is a preprocessor directive. The include directive gives a program access to the
library. The include directive tells the compiler where to find the meaning of
identifiers used in the program .
Q 25
* What is #define directive or constant Macro?
Ans * This preprocessor directive is used to define a constant macro. Constant Macro is
a name that is replaced by a particular constant value before compilation. It
cannot be changed during program execution .
Syntax:
#define Macro name expression /constant
Example: #define PI 3 142857
*

Q . 26 What is a Preprocessor?
Ans . Preprocessor is a program that modifies or handles a C program prior to its
compilation ,

Q 27
* What are Header Files?
Ans. These files contain the definition of standard library functions The extension of
*

header file is .h Each header file contains definition of one type of functions only
The include directive is used to add header files in the program All the heada
*

files are located in INCLUDE subfolder.


# include <header file name >
[ Ch # 8] Getting Started v^ ith C 212 -
Computer Science Part 11
#include "header file name”
Q . 28 What is a Main Function ?
Ans . It indicates the beginning of a C program . Every C program has a main function
and if it is not included in the program, then the compiler generates an error
message.
Syntax :
void main ( void )
f

Statements of the program // Body of main function


)
Q . 29 What arc Delimiters?
Ans . The braces in the main function represents start and end of the program, these
braces arc called delimiters.
i represents start of the code.
} represents end of the function code ,

Q . 30 What is a Statement Terminator?


Ans * Each statement of a C program ends with a semicolon ( ;) called statement
terminator. Jf statement terminator (semicolon ) is missing in any statement then
the compiler will generate the following error message:
Statement missing;
Q . 31 What is Structured Programming Language?
Ans . A programming language in which the logic of the program is divided into a
number of smaller sections . Each section of the program performs a specific
function . Those programs are easy to write, debug and modify .
Q . 32 What is Lin -Structured Programming Language?
Ans . A programming language in which the logic of the program is written in a single
module. It is very difficult to detect any error in the program . Its readability is difficult ,

Q . 33 List two reasons why it would be preferable to write a program in C rather


than machine language.
Ans * Each instruction in machine language consists of 0 ’ s and 1 ’ s therefore it is?

difficult to understand and learn it . Moreover it is difficult to locate and remove


errors in the program .
[ Ch # 8] Getting Started v^ ith C 213 Computer Science Part-11
The programs written in C language are closed to human language and programs
are machine independent i.e, a program can be run on different types of
computers.
[ Ch # gJ Elements ofC 250 Computer Science Part-11

SHORT QUESTIONS
Q* l What are Identifiers?
Ans . Identifiers arc the names used to represent variables, constants, data types,
functions, and labels in the program. Identifiers consist of characters ( alphabets,
numbers, underscore ).
Q.2 Define Standard identifiers
Ans . These identifiers have special meaning {defined operations ) in C like reserve
words . These can be redefined for other purposes but it is not recommended *

Q.3 Define User-defined identifiers:


Ans . These identifiers are defined by the programmer ( user ) . A user uses these
identifiers for variables, constants, data types, functions, and labels in the
program . These words are used to store or access data from various memory
locations *

Q .4 What are Keywords/ Reserve words?


%>

Ans. These are the words which have predefined meaning in C language. There are 32
keywords in C language Those words can not be used or redefined for any other
*

purpose in the C program. All keywords are written in lower case e .g . double,
long, void etc.
Q.5 VVhat arc Variables?
Ans. A variable is a name of memory location. Variables are used to store values that
can be changed during program execution . The value of variables may be numeric
or alphabets. Variable name remains same but the value stored in variable may
change during the program execution.
Q.6 What is a Variable definition ?
Ans. It means to set aside the memory location for the variable.
Q -7 What is Variable Declaration ?
Ans * Variable declaration tells the compiler the name and type of value stored in the
variable. Before using a variable in a program , it must be declared When a *

variable is declared, a certain number of bytes ( depending upon the data type ) arc
allocated to the variable in memory . It means declaration not only declares but
also defines a variable *

Syntax: Datatype variable names;


int a , b.c ;
Q8* Define Variable Initialization ?
Ans . Assigning a value to a variable at the time of declaration is called initialization of
variable *
[ Ch # gJ Elements ofC 25 ' -
Computer Science Part 11
Q9* What is a Garbage Value?
Ans * When a variable is declared, the compiler reserves the space for it . If we do not
initialize it then it may contain a meaningless data is called garbage value, and
with the involvement of such variable may cause unexpected results. To avoid
this situation, all variables must be declared and initialized according to program
requirement.
Q 1 ft
* Define Constants *

Ans . The quantities whose values cannot be changed during program execution. There
arc two types of constants : Numeric constants and character constants.
Example: #defme pi 3.142857
pi whose value remains same during program execution,
Q 11
* What is a Numeric Constant ?
Ans * These constants consist of numbers. There are two types of numeric constants ,
Integers and float ; Integer constants represent values that arc counted and without
decimal or fractional part . c g. + 56, -678 etc and floating constants represents
+

values that are measured e. g. 4.786, 0.45 etc .


,

Q . 12 What is a Character Constant?


Ans . It is a single alphabet, a single digit or a single symbol enclosed within
apostrophes. The maximum length of a character constant is 1 . Examples are: 5 \ L

B etc.
1

Q 13
* What is a Data Type?
Ans * Data type defines maximum or minimum set of values and set of operations on
values.
Q. 14 What is a Standard data type?
Ans . It is a data type which is predefined in C language. In C language there are four
basic standard data types (hit, float , char and double).
Q * 15 What is Llscr-dcfine data type?
Ans * It allows us to define our own data types.
Q . 16 What is Character data type?
Ans . A keyword char is used for character data type. It is used to represent a letter,
number, or a symbol A character variable occupies 1 byte in memory, %c is used
*

as format specifier . A character is enclosed in apostrophes e .g. sXy 5 \ t = \


,

etc *

Q 17
* What are integers?
[ Ch # gJ Elements ofC 252 Computer Science Part-11
Ans . Integers are the numbers without decimal fraction. It may be positive, negative or
zero. e.g. 112, -234 , 0 etc. An integer variable may be signed or unsigned . If not
mentioned then all integers are considered as signed ,

Q. 1 S What are Data Types for Integers ?


Ans . int.
short int .
long int +

Q . 19 What is int data type?


Ans . It takes 2 bytes in memory. The keyword int is used for integers . There are two
further sub-types of int variables.
Signed int
Unsigned int
Q . 20 VVhat are Signed int or Short int data type?
Ans . It takes 2 bytes in memory. The keyword signed int and short int are used for
integers. Range of hit, signed int or short int variables arc -215 to 2 -1 or -32768
to 32767 int, signed int and short int can handle both positive and negative
,

numbers. %d or % i are used as format specifiers.


Q . 21 What are unsigned int or unsigned short int?
Ans . It can not handle negative numbers. It takes 2 bytes in memory. The keyword
unsigned int is used for integers. It can handle numbers ranging from 0 to - 1
or 0 to 65535 %u is the format specifier for unsigned int .
,

Q . 22 What is long int data type?


Ans It is used to represent larger integers. It occupies 4 bytes in memory. It can hold
numbers ranging from 2 1 to - -
(i .e , 2147483648 to 2147483647} Unsigned
7
long int: can hold numbers ranging from 0 to 2 ^ - 1 ( he. 0 to 4294967295).
.

Q . 23 What are float numbers and what arc data Types for Floating Point
Numbers?
Ans . These are the numbers with fractional part e g. 243, 0 ,54 etc , ANSI C specifies
, ,

three floating point data types and All are different in memory requirement and
range.
float
double
long double
Q . 24 What is float data type?
Ans . Float may be signed or unsigned numbers. It is represented in decimal or
exponential form . It occupies 4 bytes in memory . It can store real values up to
3 Ax1 O 38 to 3 Ax1 O'* 38. Its accuracy is up to 6 decimal places.
'
[ Ch # gJ Elements ofC 253 -
Computer Science Part 11
Q . 25 What is Scientific or Exponential form of float point number?
Ans . It is a floating point number and the storage area occupied by the number is
divided into two sections . Mantissa and Exponent; Mantissa is the value of the
number and exponent is the power to which mantissa is raised. In C, scientific
forms of a number are + mep or -mep or +mEp -mEp ?

m represents the mantissa part , p represents the exponent part , E or e is used


instead of base 10, If the number is smaller than 1 then its exponent is negative ,

( i .e . 0.00524 is equal to 5.24xE-3)


Q.26 What is double data type?
Ans, It is used to stoic larger floating point numbers . It takes 8 bytes in memory It can
.

handle real numbers from 1.7x 10 -J U S to 1.7x 10+308 . Its accuracy is up to 15


decimal places .
Q , 27 What is long double data type?
Ans . A long double variable takes 10 bytes in memory . It can handle real numbers
from 3.4x 10 4932 to 3.4x 10 1-4932 . Its accuracy is up to 19 decimal places.
-

Q . 28 What is a Cancellation Error?


Ans , While working with floating point numbers , some unexpected results cause
problems . For example manipulation of very large and very small float numbers
produced unexpected results e . g the result of addition of 1970.0 and
,

0.0000001243 may produce 1970.000000 on some computers . This type of errors


is called cancellation errors i e . in cancellation errors a very small value
,

disappears when it is added to or subtracted from a very large value .


Q . 29 What is Arithmetic Underflow?
Ans . When two very small numbers are manipulated , the result may be too small to be
represented accurately , so it will be represented as zero . This is called arithmetic
underflow i .c . when the value assigned is less than the minimum allowable limit,
an underflow occurs.
Q . 30 What is Arithmetic Overflow?
Ans . When two very large numbers are manipulated, the result may be too large to be
represented . This is called arithmetic overflow i . e. When the value assigned is
greater than the maximum allowable limit , an overflow occurs .
Q * 31 What is Integer Underflow?
Ans . When the value assigned to a variable is less than the minimum allowable limit of
an integer i .e . - 32768 , an underflow occurs. In case of an integer underflow
different compiler takes different actions . But in most cases compiler runs the
programs and it produces incorrect results .
Q , 32 What is Integer Overflow?
[ Ch # gJ Elements ofC 254 Computer Science Part-11
Ans * When the value assigned to a variable is greater than the maximum allowable
limit of an integer i .e. + 32767, an integer overflow occurs . In case of an integer
overflow' different compiler takes different actions. But in most cases compiler
runs the programs and it produces incorrect results .
Q * 33 What are Comments?
Ans * It is used to add informative notes about the statements in a program that helps in
debugging and modifying programs . It is a non executable statement. Comments
play no role in the execution of the program. The compiler does not translate
these statements . It also explains the logic of the program. There are two types of
comments in C ,
Single line comments
Multi line Comments
Q , 34 What are Single line comments ?
Ans * Single line comments are inserted by typing two forward slashes before beginning
of a line.
Example:
H this program Calculates temperature
Q . 35 What is Multi line Comments:
Ans * Multi-line comments arc used to provide such informative notes which extend to
multi-lines. Multi line comments are inserted by typing slash asterisk (/*) in the
beginning and asterisk slash (*/) at the end of paragraph. Then all lines within this
block are ignored by the compiler. By omitting ending letters * / wilI cause the
whole program code beneath the opening letters /* for comments to be
commented *

Example: /* this program calculates factorial of a number


Number is positive integer. And result is long integer. * /
Q . 36 What is an Expression ?
Ans . An expression is a combination of Operands ( constants and variables ) and
operators. There are two ways to write an expression .
Operand ! operator Operand 2
Operator (operand)
There are three types of Expressions
Arithmetic Expressions
Relational Expressions
*

Logical Expressions
Q 37
* What is an operator?
[ Ch # gJ Elements ofC 255 -
Computer Science Part 11
Ans . It is a symbol or a sign used to perform a certain tasks on data. Unary operators
required single data item. Binary operators required two data items . Following
types of operators are available in C .
Arithmetic Operators, Relational Operators, Logical Operators, Increment and
decrement Operators, Assignment Operator, Bitwise operators.
Q . 38 What are an Arithmetic Expressions and Arithmetic Operators?
Ans * Arithmetic operators are used with constants and variables to form arithmetic
expressions. These operators ( +, *, /, %) arc used to perform arithmetic
operations. All arithmetic operators arc used for all types of numeric data except
remainder operator . Remainder operator or Modulus Operator (%) is used only
with integers.
Q 39 What are the modes of arithmetic expressions?
*

Ans . Integer Arithmetic


Real Arithmetic
Mixed arithmetic
Q . 40 What is Integer arithmetic Mode?
Ans * When an arithmetic operation is performed on integer values it always yields an
integer result . It does not produce real results .
Q . 41 What is Real arithmetic Mode?
Ans * When an arithmetic operation is performed on floating point numbers, it always
yields a floating point result,

Q .42 What is mixed arithmetic mode?


Ans . When an arithmetic operation is performed on integers and floating point numbers
( anyone is real number ), it always yields a floating point result
Q . 43 What are Relational Expression and Relational Operators?
Ans . Relational operators with constants and variables form relational expressions.
These arc six operators (<, >* <= >= !=) used to compare two values. These
always evaluates to true or false A true state is represented by a non zero value
,

( 1 ) A false state is represented by a zero value (0).


Q * 44 What are Logical Expressions and Logical Operators?
Ans * These operators are used to combine more than one relational expression i .e ,

relational expressions with logical operators form logical expressions. And ( & & ),
or (||) and not (!) are three logical operators. Logical operators also produce true
or false results, Not ( ! ) is a unary operator but && and || arc binary operators.
Q *45 What is And Operator ( && )?
[ Ch # gJ Elements ofC 255 Computer Science Part-11
Ans . It is used to combine two or more relational expressions. It produces true if all the
relational expressions (conditions ) are true.
Q 46 What is Or Operator (||):
*

Ans * It is also used to combine two or more relational expressions. It produces false if
all the conditions ( relational expressions ) are false. It produces true result if any
one of the conditions or all the conditions are true ,

Q . 47 What is Not or Negation Operator (!)?


Ans . It negates the value of an expression. If an expression evaluates to true then it
converts true into false. If an expression produces false then its negation yields
true.
Q 48 What is Increment Operator (++):
*

Ans . ++ is used as increment operator. It is used to increase the value of the variable by
one It can be used before or after the variable name e.g , x or ++x , It cannot be
*

used with constants and expressions . Only the variables can be incremented . It is
unary operator. There are two types of increment operator
Postfix increment operator
Prefix increment operator.
Q * 49 What is a Postfix increment operator ?
Ans . When is follows its operand ( variable ), it is called postfix increment operator.
In postfix increment , ++ increases the value of variable after the execution of the
statement i . e. it first uses the current value of the variable in the statement and
after the completion of the statement it increases the value by one ,

Q .50 What is a Prefix increment operator?


Ans. When ++ is precedes its operand (variable), it is called prefix increment operator,
In prefix increment , ++ increases the value of the variable before the execution of
the statement i , c. it first increases the current value of the variable by one and then
new value is used in the statement .
Q .51 What is Decrement Operator
Ans * - is used as decrement operator. It is used to decrease the value of the variable by

one. It can be used before or after the variable name e. g. x or ~x. It cannot be
used with constants and expressions . Only the variables can be decremented . It is
unary operator. There are two types of decrement operator
Postfix decrement operator
Prefix decrement operator .
Q .52 What is a Postfix decrement operator?
Ans * When - is follows its operand ( variable ), it is called postfix decrement operator.
In postfix decrement, - decreases the value of variable after the execution of the
[ Ch # gJ Elements ofC 257 -
Computer Science Part 11
statement i.e it first uses the current value of the variable in the statement and
,

after the completion of the statement it decreases the value by one .


Q .53 What is Prefix decrement operator?
Ans . —
When is precedes its operand (variable), it is called prefix decrement operator.
In prefix decrement , — decreases the value of the variable before the execution of
the statement Le. it first decreases the current value of the variable by one and
then new value is used in the statement ,

Q .54 What are Assignment Statement and Assignment Operator (=):


Ans . Assignment statement is used to assign a value or a computational result to a
variable. The symbol equal {= ) represents assignment operator e .g. a=2;
There are two types of assignment statement .
Simple Assignment Statement
Compound Assignment Statement
Q .55 What is a Simple Assignment statement?
Ans * The value is written on the right side of the operator and the variable is left side of
the operator in the assignment statement . Writing variable to right and value to
left causes a syntax error. General form of assignment statement is :
Variable = expression
Expression can be a variable, constant, arithmetic, relational or logical expression
Q .56 What is Compound Assignment statement?
Ans . It is used to assign one value to more than one variable. General form of
compound Statement
Var-1 = Var- 2 = Var-3 = = Var- n = Value
Q 57 What are Compound Assignment Expression and Compound Assignment
,

Operators?
Ans . It is used to add , subtract , multiply or divide the value to or from a variable. There
are four compound assignment operators {+= -=, *=, /=) that can increment or
decrement the value of the variables by other than one. General form of writing
compound assignment expressions is
Variable operator value
0 58 What is Operator Precedence?
Ans . It determines the order of evaluation in an expression . Each operator has a fixed
order. The operator with higher priority evaluated before those with lower
priority. When an expression is a combination of arithmetic, relational and logical
expression then the expression is evaluated in the following sequence.
[ Ch # tf Elements ofC 258 Computer Science Part-11
Arithmetic
Relational
Logical
[ Ch # io] Inpwt/Outpid 2 So -
Computer Science Part 11

SHORT QUESTIONS
Q. l What is an output Statement?
Ans * Output statements (functions) are used to get data from the program . Output
produced by monitor is called standard output e .g. printf{ )
Q.2 What is an printf( )?
Ans , It is used to display messages . It can be accessed by including standard input /
output header file stdio .h in the program. It takes formatted string and list of
variables as ail argument . The values of variables are displayed according the
specified format in the string.
printf("Fonnat specifiers Control string" , var- L , var-2, );
Q,3 What are Format Specifiers?
Ans * A format specifier represents data type field width and format of a value of a
variable displayed on the screen. A format specifier always begins with the
symbol %. format specifiers are used for both input and output statements. For
different types different format specifiers are used e. g. %d > %s %c, etc .
?

Q4* What is Field Width Specifier?


Ans , It is defined as the number of columns used to display a value on the screen . Its
use is optional . If the value requires more columns, then the field is expanded . If
the value is smaller than the specified number of columns then the extra spaces
are padded before or after the value .
Q5* What is an Escape Sequence?
Ans , These characters are used to control output on the output devices . These
characters are not printed on the output devices. An escape sequence is a
combination of a backslash and a single character . Backslash \ is called control
character. And next single character after backslash is called code character,
These are used in control string. These characters cause a different meaning from
the normal interpretation c.g. \n represents new line, \t shows tabs etc ,
Q.6 What is an input Statement?
Ans , Input statements ( functions ) are used to provide data to the program. The input
given o the computer through keyboard is called standard input . There are two
types of input
Design time input
[ Ch # io] Inpwt/Outpid 28 ? -
Computer Science Part 11
Run time input
Q .7 What is Design Time Input ?
Ans . It is also called programmer’s input or simple input. It is given by the programmer
at the time of writing programs ( coding) . It remains constant during the execution
of the program . Example: int x= 5.y=9;
Q .8 What is Run Time Input?
Ans . It is given at the time of execution of the program (after compilation). It is called
user input. scanf{ ) getch ( ), gctehe( ) arc the functions to get run time input .
?

Q .9 What is scanf{) Function?


Ans * It is used to get values of the variables ( numeric and string) from user . It can be
accessed by including standard input l output header file stdio. h in the program
( means stdio. h is a prototype for scanf ( ) function ). It takes formatted control
string and list of variables as an argument to hold the value of variables . scanf ()
requires the address of the variable to store the value into it. Ampersand sign ( & )
is used before the variable name as an address of operator If & sign is omitted the
scanf function will not locate the variable in memory .
Syntax : scanf( List of Format specifiers” , & var - l , &var-2? &var-3
44
; );
Q . 10 What is a getch ( ) Function ?
Ans * It is used to get a single character as input from the keyboard during the execution
of the program. The prototype of getch ( ) function is conio. h ( console
input /oulput ) header Hie. It docs not accept any argument. There is no
requirement of pressing enter key after typing the character.
Syntax : getch ( ); or vai iable name = getch ( ); variable name is optional.
Q. l 1 What is getche ( ) Function?
Ans * It is used to get a single character as input from the keyboard during the execution
of the program. The prototype of getch ( ) function is conio. h ( console
input output ) header file. It does not accept any argument, there is no
requirement of pressing enter key after typing the character.
Syntax: getehc( ); or variablcname = getchc( ); variable name is optional .
Q. l 2 What is the difference between getch( ) and getche{ ) functions
Ans . getch( ) does not display the entered character on the screen while getche ( )
displays the entered character on the screen.
[Cfi#nJ Decision Constructors 311 -
Computer Science Part 11

SHORT QUESTIONS
Qi What is a Control Structures ?
Ans . These are the statements used to control the flow execution in a program or function.
These instructions enable us to group individual instructions into a single logical unit
with one entry point and one exit point . All programs use control structures to
implement the program logic, There are three types of control structures:
Sequence
Selection
Repetition / iteration / loops:
Q-2 What is a Sequence?
Ans . The instructions are executed in which they are written in the program .
Example: compound statement:
f
I

Statements
St - 1
St - 2

}
Q.3 What is a Selection?
Ans . A structure that selects which statement or block of statements is to execute .
Examples: if - else, switch
Q4 What is a Repetition / iteration/ loops?
Ans . These statements are used to repeat set of statements .
Examples: for- loop, while loop, do- wrhile loop
Q .5 What is if statement?
Ans . if is a keyword in C language. It is used to execute or ignore a set of statements
after testing a condition. A condition is a relational or logical expression and it
produces either true (means 1) or false ( means 0 ) result. If the condition is true
then the block of statement is executed . If the condition is false then the block of
statement is ignored and the control is transferred to the next statement after if
statement.
[Cfi#nJ Decision Constructors 3!2 -
Computer Science Part 11

Q .6 What is Syntax of if- statemeni?


Ans . if ( relational or logical condition )
{
Block of statements
}
next statement after if
Q7. What is If -elsc statement:
Ans. It is similar to if statement . It is also used to execute or ignore a set of statements
after testing a condition. In if-else statement one condition and two blocks of
statements arc given . A condition is a relational or logical expression and it
produces either true or false result . If the condition is true then the first block of
statement is executed. And after executing the first block , the control is
transferred to next statement after if-else structure. If the condition is false then
the first block of statement is ignored and the 2 nd block of statement is executed.
Q.8 What is Syntax of if-else statement?
Ans. if ( relational or logical condition )
{
first Block of statements
}
else
{
2 "d block of statements
}
Next statements after if- else
Q.9 What is a Conditional Operator or Ternary Operator?
Ans . It is use as an alternative to simple if-else statement . It is also called ternary
operator. It requires three expressions. First expression is relational or logical
expression (condition ) and it produces either true ( means 1 ) or false ( means 0 )
result. If the condition is true then 2nd expression following question mark ( after
?) is executed . If the condition is false then the 2 lkl expression is ignored and 3 rd
expression after colon (:) is executed .
[Cfi#nJ Decision Constructors 3!3 -
Computer Science Part 11
Syntax :
v
Conditional Statement ? true case statement : false case statement ;
Q. 1 U What is a Switch Statement?
Ans . Switch is used to select one option from a set of options . It is also a control
structure. It compares the value of an expression against a list of cases. The case
labels and the value of expression must be an integer or a character. It must not be
a float or double value. If the value of expression in switch is float or double type
then the compiler will generate the following error message . Switch selection
expression must be of integral or character ,

Q . ll What is a Syntax of switch


Ans . swjtch ( expression )

{
case val - 1 :
statements - 1 ;
break;
case val - 2:
statements - 2 ;
break;
case val - 3 :
statements - 3;
break;

case val - n :
statements - n;
break;
default:
statements ;
}
Q . 12 What is the function of break statement ?
Ans . It must be included at the end of each case statement in switch. It is used to exit
from the body of switch. If all break statements are omitted then the code of other
cases after the matching ease will be executed sequentially.
0- 13 What is the function of default keyw ord ?
[Cfi#nJ Decision Constructors 314 -
Computer Science Part 11
Ans . Its use is optional in switch . If none of the case label is matched . Then the
statements under default are executed. The position of default is not fixed. It may
be placed before the first case or after the last case .
Q . 14 What is the Ncstcd -if statement?
Ans . if statement within another if statement is called nested if statement . It is used for
multi-way decision-making. Nesting can be done up to any level . The else
statement is optional . It may be used with outer or inner if statement . Increase in
nesting also increase the complexity of program.
0- 15 What is Syntax of Nested if?
Ans . if(condition- l )
{
if( condition -2 )
{
statements of inner if
}
}
Q . 16 What is if -elsc-if statement?
Ans . If there are more than three alternatives, then we use if-else-if instead of nested if
statement. It is used when multiple options are available. Nesting can be done up
to any level . The conditions in if are evaluated in a sequence. All the conditions
are evaluated until a true condition is reached. When a true condition is found ,
then the statements under true conditions are executed and the remaining
conditions are ignored. If all conditions are false, then the last statement - k after
else is executed .
Q . 17 What is a Syntax of if-else- if?
Ans . if(condition - l )
statement - 1
else if ( condition -2)
statement - 2
else if ( eondition -3)
statement - 3

else if ( condition -n )
[Cfi#nJ Decision Constructors 3 ]5 -
Computer Science Part 11
statement - n
else
statement - k
[ Ch #iaJ Loop Constructors 352 Computer Science Part - fl

SHORT QUESTIONS
Q. l Define loop?
Ans . Jt is a statement that is used to repeat a set of statements up to a fixed number of
times or until a given condition is satisfied . There are three types of Loops
-
Conditional Loop { while and do while loop )
Counter loop ( For Loop )
Q.2 What is a Conditional Loop?
Ans . Tt is a loop that executes a set of statements as long as a given condition remains
true. There are two types of conditional loops
While Loop
do-while Loop
Q.3 What is while Loop ?
Ans . While loop statement is used to repeat a set of statements until a given condition
is satisfied .
Syntax:
While ( Relational or logical expression Le. condition )
{
Statements ( Body of loop )
}
Q.4 What is the working of w hile loop ?
Ans . When while-loop is executed , the computer chocks the given condition written in
parentheses. If the given condition is true then the statements enclosed in the
braces ( body of loop ) are executed. After the completion of first iteration control
is shifted to while and the condition is again tested . This process is repeated until
the condition is true. If the condition is false then control is transferred the
statement that comes after the body of loop .
Q .5 What is an infinite loop ?
Ans . If the condition of loop never false then the loop never terminates and it is called
infinite loop; for infinite loop there must be a statement in loop body such that the
condition in while loop always true.
Q .6 Why we use of while loop?
Ans * It is useful where the programmer does not know in advance howr many times the
body of loop will be executed .
[ Ch #iaJ Loop Constructors 353 Computer Science Part - fl
Q7* What is Loop control variable?
Ans * A variable whose value controls the number of iterations is known as loop control
variable. Loop control variable is always initialized before starting of the loop and
incremented and decremented inside the loop body,
Q .8 What is do-while Loop ?
Ans . It is similar to while loop i e. do- while loop is used to repeat a set of statements
,

until a given condition is satisfied. In do-while loop condition is tested after the
end of loop body. In do- while the condition is written at the end of loop body
therefore loop is executed at least once.
Syntax :
do //keyword and starting of loop
{ // beginning of loop ody
Statements
} // end ot loop body
While ( Relational or logical expression i .e. condition );
Q.9 What is a Counter Loop?
Ans * Counter loop is used to repeat a set of statements for a specified number of times.
Example: for loop
Q . 10 What is a For Loop?
Ans * This loop is used to repeat a set of statements for a fixed number of times i . e. in
for we know how many times the body of loop is executed .
Syntax :

for( initialization ; condition; increment/decrcmcnt)


{
Statements ( loop body)
}
Q . ll What is Nested Loop ?
Ans * Nested loop mean loop inside the body of another loop is called nested loop.
Nesting can be done up to any level . Nested loop increases the complexity of the
program . There is no restriction on the type of loops that may be placed in the
body of other loops.
Q 12 What is Sentinel controlled loop?
*
[ Ch #iaJ Loop Constructors 354 Computer Science Part - fl
Ans . The values are used to end the loop are called sentinel values and the loop that ends
with a sentinel value is called sentinel controlled loop. Sentinel loop is used when
exact number of repetitions is unknown. General form of sentinel controlled loop :
Get a data value.
Compare data value with sentinel value.
If it is not sentinel value then process the data .
Get another statement of data using loop.
Q . 13 What is a goto Statement?
Ans * The goto statement performed unconditional transfer of control to the named
label . The label must be in the same function .
Syntax :
goto label;

label : statement
Q . 14 What is an array?
Ans . It is a collection of variables stored in a contiguous portion of memory having
common name and same data type. Each element of an array has separate
subscript. The index always staits with 0.
Datatype array _namc|size| ; // Declaration of the array:
[ Ch # i 3 Functions
j
377 -
Computer Science Part 11

SHORT QUESTIONS
Q. l What is a Function or modular programming?
Ans. A function is a complete independent program that performs a specific function.
The main function calls these types of functions according to requirement of a
program . A program may have repetition of piece of code at various places and it
is very difficult to understand and debug larger programs, therefore, a larger
program is divided into simple and independent modules called functions ad this
type of programming is called modular programming.
Q.2 What are types of functions ?
Ans . There are two types of functions in C.
Built -in functions
User defined functions .
Q.3 What are Built-in functions?
Ans . These are predefined functions provided by high-level language. All built -in
functions are available in library and therefore called library functions. All the C
library functions are defined in header files, which must be included in writing C
program . Examples are: printff ) and scanf( ) functions use stdio. h, sqrt( ) function
uses math . h
Q.4 What are user-defined functions?
Ans . The functions created by user are called user-defined functions. There arc three
steps to create a user-defined function .
Function prototype or function declaration.
Function definition .
Function calling.
Q .5 What is Function Prototype or Function Declaration ?
Ans, It is a statement that provides the basic information that the compiler checks and
uses a function correctly The function prototype (declaration) consists of name of
,

function its return type, number of parameters and type of parameters


(arguments). Function prototype is usually written before main function .
Syntax:
Retumtype function name (parameter list);
[ Ch # i 3 Functions
j
37« -
Computer Science Part 11
Q .6 Explain the concept of Return type in function declaration .
Ans . Jt represents the data type returned by the function e. g. int , float . If the function
does not return any value then the keyword void is used as return type.
Q .7 What are Parameters ( arguments ):
Ans . The information provided to the functions is called parameters or arguments , In
function declaration wc specify the type of parameters separated by comma . If no
parameter is used the keyword void is used between the parenthesis.
Q .8 What is a Function Definition ?
Ans . Variable declaration and the function logic are implemented in function
definition. The actual code of the function is called function definition . It is
written outside the main function ( before or after ) . There are two parts of the
function definition
Function header
Function body.
Q .9 What is a Function Header?
Ans. It is the first line of the function definition . It is similar to function declaration . It
is not terminated with semicolon e. g. int add ( int x, int y)
Q . l ftWhat is a Function Body?
Ans . Variable declaration and the function logic are implemented in function
definition. It is enclosed in curly braces.
Q . l 1 What is return Statement?
Ans . The return statement in the function body is used to specify the value returned by
a function . It is usually the last statement in the function body . The general form
of return statement is
return value/variable/expression ;
When return statement is executed, expression is evaluated and returned as the
value of the function . Execution of the function body stops when the return
statement is executed , If the type of function is void then there is no need of
return statement .
Q . 12 What is Function Calling process ?
Ans . It is a process that is used to invoke a function to perform a specific task . A
function can be called at any point in the main program. A function can be called
with its name and correct sequence of parameters . When function call statement is
executed. Then the control is transferred to the function body. And the statements
in function body are executed. After executing the last statements in the function,
the control is transferred to the calling function .
[ Ch # i 3 Functions
j
379 -
Computer Science Part 11
Q . 13 What are local variables ?
Ans . All variables that we have declared within a pair of curly braces are called local
variables and their scope is local . The local variables can only bo accessed in the
function in which they are declared . They are not available outside the function .
These are also called automatic variables . Variables in the functions are
automatically created when the function is executed and destroyed when the
function terminates .
Q . 14 What is life time of a variable ?
Ans . The lifetime of a variable is the duration in which a variable exists in memory (the
creation and destruction of the memory variable ).
Q . 15 What is the scope of a variable?
Ans . The scope of a variable refers to the region of a program in which it is accessible .
The name of a variable is valid only within its scope not outside the scope.
Q . 16 What are global variables ?
Ans . The variables declared outside all the blocks of the program. These are also called
external variables. These variables can be accessed in any function at any time
during the execution . They are available for all the functions in the program ,
following their point of declaration. The lifetime of a global variable is until the
termination of the program.
[ Ch # i 4] ble Handling in C 405 -
Computer Science Part 11

SHORT QUESTIONS
Q1* What is a File?
Ans * The data is stored in the form of files . A file is a set of related records .
Q.2 What is a Stream?
Ans , A stream is a logical interface to a flic, A stream is associated to a tile usinu an
open operation. A stream is not associated to a file using a close operation . Stream
refers to flow of data from source to destination There are two types of streams.
*

Text Stream
Binary Stream
Q3* What are Text Streams?
Ans . A text stream is a sequence of characters . Character translations may occur in a
text stream e.g new line is represented as carriage return . There may not be one to
*

one relation between the characters written and those on the external device.
Q.4 What is a Binary Stream ?
Ans . It is a sequence of bytes . The number of bytes written or read is always the same
as those on the external device. It means there is one to one relation between the
bytes written or read and those on the external device . No character translations
occur in binary stream. Some additional bytes such as the file sector on the disk
are added to the binary stream.
Q .5 What is BOF?
Ans * The start of first byte or character in a file is called Beginning of file (BOF )*

Q .6 What is EOF?
Ans . The end of last byte or character in a file is called End of file ( EOF ). EOF
characters arc placed after the last character in C .
Q .7 What is Current position ?
Ans * The position where data read or data write operations are performed is called
current position.
Q8* What is new line?
Ans . Enter key is used in text editor for new line but in C new line character is \ n to be
placed at the end of each line*

Q .9 What is File Opening?


[ Ch # i 4] Fib Handling in C 40G -
Computer Science Part 11
Ans * Before read or write operations, a file must be opened . All standard file handling
functions of C are declared in stdioJi, When a tile is opened , a potion of memory
is reserved for file to read and write this memory is called memory buffer .
Q. 1 U What is flushing of buffer?
Ans . The transfer of data from buffer to the disk is called flushing of buffer. The
writing and reading through file through disk is time consuming, therefore time of
reading and writing data to a file is reduced through buffer.
Q . ll What is a Pointer?
Ans. A pointer is like a variable whose content is the address of another memory cell
(variable). * represents a pointer to the variable with which it is used
Q . 12 What is a fiJe pointer?
Ans. A tile is not directly accessible in C . Files are accessed through I/O buffers. A file
pointer is a variable of FILE type defined in stdio.h FILE * represents a pointer to
a variable of FILE type
Q . 13 What is fopen ( ) function?
Ans . The fopen ( ) function is used to open a file. The function prototype is:
FILE * fopen( const char *filename, const char * modc); or
FILE * fp; // it specifies the file pointer.
fp = fopen (file, mode );
The lopen function returns the null pointer, if it fails to open the file (most
common reason is file does not exist) .
Example : FILE * fpr

Q . 14
-
fpr fopen (“ CAVTCWXYZ.DAT” , V’);
What is File opening Modes/ File Access Modes?
Ans * A file can be opened to perform various operations e , g , reading, writing
appending, these operations are represented as modes e. g. “ 1 is used for reading.
"

Q . 15 What is the meaning of “ r” in file opening modes?


Ans . “ d open a text file for reading, each file must exists before reading ,

Q . 16 What is the meaning of “ w" in file opening modes?


Ans * <(
w” open a text file for writing, if the file already exists then it contents are
overwritten, if il does not exists, it will be created .
Q . 17 What is the meaning of “ a ” in file opening modes?
Ans . “ a” open a text file for append . Data is appended at the end of existing file . If the
file docs not exist , it will be created.
Q . 18 What is the meaning of ur+ ” in file opening modes ?
“ r -E opens a file for both reading and writing. The file must already exists
:
Ans .
[ Ch # i 4] Fib Handling in C 407 Computer Science Part 11 -
Q . 19 What is the meaning of ** \v+ ” in file opening inodes ?
Ans * “ w+" opens a file for reading and writing, its contents are overwritten If the file
*

does not exist , it is created.


Q . 20 What is the meaning of “ a+ ” in file opening modes?
Ans * “ a +" opens a text file for both reading and appending. If the file does not exist it ,

is created for both reading and writing.


Q * 21 What is File Closing?
Ans . An open file must be closed after completing the tasks . When a file is closed then
the buffer is flushed ( data is transferred on the disk). If the file is not closed then
the data may be lost .
Q * 22 What is fcluse( ) function?
Ans . The fclose{) function is used to close a file.
Syntax :
fclose( fp );
Where fp is a file pointer associated to a file which is to be closed fclosef ) ,

function returns 0 if the close operation is successfully completed . felose()


function returns EOF if any error occurs.
Q . 23 What is the function of putc( )?
Ans . The putc ( ) function writes a single character to the file. The putc( ) function
returns the character, if it successfully writes it The putc( ) function returns the
*

EOF if an error occurs .


Syntax :
putc(character ch , file pointer);
Character ch can be character, int , constant or a variable. File pointer specifies
variable of FILE type associated with the file in which character is to be written .
Q * 24 What is the function of getc{ ) ?
Ans . The getc( ) function reads the next character from the file. If an error occurs it
returns EOF. The gete{ ) function also returns EOF when the EOF is
encountered . The file must be in open mode to use this function. It automatically
moves the next character when it this function is again used.
Synatx :
Variable = getc ( tile pointer);
Variable is a character variable to which the character read from the file.
Q . 25 What is a string and w hat is the function of character array in strings?
'1
Ans * String is a combination of characters and it is enclosed in double quotes e g. “ ah ,

Character array is used to hold strings.


char nameofstringvariable [sring length ];
char is data type and string length is the number of characters m a string. A string
variable can also be declared without specifying the number of characters . The
[ Ch # i 4] Fib Handling in C 408 -
Computer Science Part 11
variable that is used to store a string is called string variable The last character of
*

a string must be a Null character \0 i . e. Null character \0 is added to the end of the
string. Null character \G is also included in the string length . C uses string . h
header file to handle the strings.
Q . 26 What is a string variable?
Ans, The variable that is used to store a string is called string variable *

char name of string variable [sring length ];


A string variable can also be declared without specifying the number of
characters . The last character of a string must be a Null character \0 i.e Null ,

character \0 is added to the end of the string. Null character \0 is also included in
the string length . C uses string. h header file to handle the strings .
Q . 27 VVhat are the most common string functions?
Ans . fputs ( )
fgets( )
strcpy ( )
Q . 28 What is the function of fputs{ )?
Ans * It is used to write a string of characters in to a filc.This function writes the string
until the null character \0 is rcachcd . lt does not add the null character to
the file. The file must be opened or in append mode to write this function.
Syntax:
fputs ( string, filepointcr )
string are the characters that are to he written in the file *

Example:
FILE *fp;
fp = fopen (“ testl W” , i£ w ” );
fputs{wThe String of your choice :w , fp );
The above string is written in testl .txt file .
Q , 29 What is the function of fgetsf ) ?
Ans, It is used to read a string of characters of a certain length from a file The file
*

must be opened or in append mode to write this function .


Syntax :
fgets( string or string variable, 14 file_pointer)
V

n is the number of characters read from the file .


Q . 3 fl What is Formatted I /O ?
Ans . The formatted file input and output functions are used for reading and writing
formatted data In formatted I/O data is read or data is written in a specific manner
*

in the file *

Q . 31 What is the function of fprintf{ )?


Ans . The fprintf( ) function is used for formatted output in a file Its Syntax is:
*

fprintf (file_ pointer, control string , arguments) ;


[ Ch # i 4] File Handling in C 409 -
Computer Science Part 11
The arguments are variables and are optional ,

0 32 What is the function of fscanf ( )?


Ans * The fscanf{ ) function is used to read formatted data from a file. Its syntax is:
fscanf (file_pointer, control _string, arguments) ;

You might also like