Computer 12 Class Notes (Short)
Computer 12 Class Notes (Short)
•
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 ,
the computer for input and information is received from the computer in the form
of output ,
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
*
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 *
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 ,
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 :
,
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
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 *
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
* *
SHORT QUESTIONS
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 ,
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.
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
*
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
*
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 / / ,
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 ,
-^
Ans . Machine language instructions s and Ts ) are replaced with English like words
1
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 ,
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
*
#define *
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
*
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 *
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 *
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
+
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
*
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 . 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 ?
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?
*
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 ,
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 ,
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 .
?
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
{
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 :
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
,
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 . 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.
"
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 *
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
*
in the file *