[go: up one dir, main page]

0% found this document useful (0 votes)
10 views23 pages

Short Notes Computer Science

The document contains important short questions and answers related to computer science topics for 2nd year ICS students, covering data basics, database concepts, data integrity, normalization, and Microsoft Access. It includes definitions and explanations of key terms such as data processing, fields, records, databases, and various types of keys. Additionally, it discusses the database design process, integrity constraints, and provides insights into programming languages and their characteristics.

Uploaded by

sherijootah
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)
10 views23 pages

Short Notes Computer Science

The document contains important short questions and answers related to computer science topics for 2nd year ICS students, covering data basics, database concepts, data integrity, normalization, and Microsoft Access. It includes definitions and explanations of key terms such as data processing, fields, records, databases, and various types of keys. Additionally, it discusses the database design process, integrity constraints, and provides insights into programming languages and their characteristics.

Uploaded by

sherijootah
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/ 23

COMPUTER SCIENCE NOTES

Class 2nd Year ICS (Important Short Questions)

WRITTEN BY PROF M.JUNAID YASEEN

Contact for any query: 0304-8613604


Ch#1: Data Basics
Short Questions
Q.1. What is data processing?
The process of manipulating data to achieve the required objectives and results is called
data processing. The software is used to process raw data. The software converts raw is data
into meaningful information.
Q.2. Define field.
A combination of one or more characters is called field. It is the smallest unit of data a
that can be accessed by the user.
Q.3. Why is it important to specify data type and size of a field?
The data type of a field specifies the type of data that can be stored in the field. A field
size defines the maximum number of characters that can be stored in a field.

Q.4. What is meant by a record?


A collection of related fields used as a single unit is called a record. For example, an Q.2
employee's record includes a set of fields that contains EmployerID, Name, Hire Date, JobTitIe
and Phone etc.

Q.5. What is a file?


A collection of related records used as a single unit is called file. File is also known as
data set. Files are stored on different storage media such as hard disk, USB flash drive or acc
optical disc etc.

Q.6. Define program file.


A type of file that contains the software instructions is called program file. A program file
has an extension of .com or .exe. These files contain the instructions that can be directly
executed by the computer.

Q.7. Define data file.


A type of file that contains data is called data file. Data files are created by the software
being used. A data files is generally opened in the same software in which it is created.

Q.8. What do you mean by file organization?


A technique for physically arranging the records of a file on secondary storage devices is
called organization.
Q.9. Define database.
A database is a collection of logically related data sets or files. Each file may contain
different type of information and are used for specific purposes. The files may be organized in
different ways to meet different processing and retrieval requirements of the users.

Q.10. Define data redundancy.


Data redundancy means the duplication of data in multiple files.

Q.11. Define data inconsistency.


Data inconsistency means that two files may contain different data of same entity.

Q.12. Which problems occur due to data redundancy?


Redundant data uses additional storage space and makes it difficult to maintain the
accuracy of database when changes are made.

Q.13. What is a database system?


A database system is a collection of data as well as programs required to manage that
data. It is computerized record-keeping system.

Q.14. Define DBMS.


A database management system is a collection of programs that are used to create,
maintain and access database in a convenient and efficient manner.

Q.15. What do you mean by integrity of data?


Integrity of data means that data in database is always accurate. Different integrity
constraints are enforced on the database to maintain the integrity of data. A DBMS should
allow the user to define and enforce the integrity constraints.

Q.16. Do you know the most popular query language?


The most popular query language is SQL. It stands for Structure Query Language.
The statements of SQL are written in simple English-like sentences.

Q.17. What is the use of DDL?


DDL stands for Data Definition Language. It consists of SQL commands used to
define a database, creating tables, indexes and views. Some important commands of DDL
include CREATE/DROP TABLE, ALTER TABLE, CREATE/DROP VIEW etc.
Q.18. What is the use of DML?
DML stands for Data Manipulation Language. It consists of SQL commands used to
load, update and query the database using SELECT command. INSERT, UPDATE and
DELETE are some examples of DML commands.
Q.19. What is the use of DCL?
DCL stands for Data Control Language. It consists of SQL commands used to
establish user access to the database. Some important commands of DCL are GRANT, ADD
USER and REVOKE etc.

CH#2: Basic Concept and Technologies of Databases


Short Questions
Q.1. How is data handled in file management system?
The file management system uses files to handle data. The files contain records that consist of
related fields. Each field in the record has a starting address. The starting address of each field and its
length is used to identify its storage location. The field name IS used as a name reference to Store and
retrieve data.
Q.2. What is entity?
An entity is anything about which information is stored in the database. An entity may
have many attributes with unique names.
Q.3. Define view.
A View is a virtual table that displays the data from one or more tables.
Q.4. How are views created?
Views are created by using a SQL query. A view can be created from one or mom tables. The
CREATE VIEW command of SQL is used to create view
Q.5. Define key.
key is an attribute or set of attributes that uniquely identifies a tuple in a relation.
Q.6. List different types of keys.
Different types of keys used in databases are primary key, secondary key, candidate or
alternate key, composite or concatenate key, sort or control key and foreign key.
Q.7. Define primary key.
The attribute or combination of attributes that uniquely identifies a row or record in a relation is
known as primary key.
Q.8. What is secondary key?
A secondary key is an attribute or combination of attributes that can be used to acc—s or retrieve
records. Secondary key values may not be unique. One secondary key value may refer to many records.
Q.9. Define composite key/ concatenate key?
A primary key that consists of two or more attributes is known as composite key.
Q.10. Define foreign key.
A foreign key is an attribute or combination of attributes in a relation whose values
match a primary key in another relation. The table in which foreign key is created is known as
dependent table. The table to which the foreign key refers is known as parent table.
Q.11. What is the purpose of index file?
The indexes are stored in index file. Database management system uses this file to speed
up the sorting and searching operations.
Q.12. Who is the user or ender user?
A user or end user is a person who uses computers for his specific needs. He might have a
moderate knowledge of computers, computer science and information technology. He does not need
to know in-depth knowledge of computer system.
Q.13. Who is a data administrator?
A data administrator is a person who is responsible for entire data of an organization. He
normally develops the overall functional requirements for the database being used in the office. He
controls and manages the whole database system.
CH#3: Database Design Process
Short Questions
Q.I. Define the term analysis.
A process of studying the existing system is known as analysis.
Q.2. What is the purpose of analysis?
The basic purpose of analysis is to know which activities are performed in the current
system. The analysis also determines what should take place in the new system. Q.3. Write
the purpose of feasibility study.
Q.3. Define entity or object.
Anything that is participating in the system is known as entity or object, an entity can be a
person, place, thing or event for which data is collected and maintained in the system.
Some examples of entity are TEACHER, CITY, TOY and SALE etc.
Q.4. Define an attribute. Give examples.
The characteristics of an entity are called attributes or properties. Some example of
attributes of teacher are name, Gender and telephone etc. An attribute is represented by an oval.
Q.5. What is a relationship? Give an example.
A logical connection between different entities is called relationship. For example, a
relationship exists between a STUDENT and TEACHER because teacher teaches student. The
entities that participate in a relationship are called participant.
Q.6. What is meant by file organization?
File organization is a technique for physically arranging records of a file on
secondary devices. The system designer must recognize several constraints to select a
file organization.
CH#4: Data Integrity and Normalization
Short Questions
Q.1.What do you mean by data integrity?
Data integrity means the correctness and consistency of data. It is another form of
database protection. It is maintained with the help of integrity constraints.
Q.2. What is meant by entity integrity?
The entity integrity states that any attribute of a primary key cannot contain a null value. It
is because the primary key is used to uniquely identify a record in the relation. It is not possible
to uniquely identify a record in a relation if primary key contains null value.
Q.3. How is entity integrity attained?
The entity integrity can be attained by specifying primary key in a relation. DBMS
automatically applies the entity integrity on the attribute that is used as primary key.
Q.4. Define referential integrity.
The referential integrity states that if a foreign key exists in a relation, the foreign key
value must match the primary key value of some tuple in its parent relation.

Q.5. Define synonym.


A synonym is a type of problem in the relations that occurs when two different names are
used for the same attribute.

Q.6. What is homonym?


A homonym is a type of problem in the relations that occurs when the same name is used for two
different attributes. Different names must be used for different attributes.

Q.7. What do you mean by redundancy?


Redundancy is a type of problem in the relations that occurs when unnecessarily stored in
two different Ways or forms.
Q.8. What are the database anomalies?
Database anomalies are the problems in relations that occur due to redundancy in the relations.
These anomalies affect the process of inserting, deleting and modifying data in the relations.
Q.9. Write three types of database anomalies.
Three types of database anomalies include insertion anomaly, deletion anomaly and modification
anomaly.
Q.10. Define normalization.
The process of producing a simpler and more reliable database normalization
Q.11. Why is normalization used?
Normalization is used to create a suitable set of relation for storing data. It identifies and
correct problems and complexities of database design. It produces a new set of consistent
relations. The new design is as free of processing problem as possible.
Q.12. What is functional dependency? Give an example.
A functional dependency is a relationship between two attributes. It states that if the
value of one attribute is known, it is possible to obtain the value of another attribute. An
example of functional dependency: Roll No Marks.
Q.13. What is a repeating group?
A repeating group is a set of one or more data items that may occur a variable
number of times in a tuple. Each cell in a relation should contain only one value.
Q.14. Define partial dependency.
A type of dependency in which one or more non-key attributes are functionally
dependent on a part of primary key is called partial dependency.
Q.15. When is a relation in second normal form?
A relation is in second normal form (2NF) if It is in INF and every non-key attribute
is fully functionally dependent on the primary key. All non-key attributes must 'depend on
all parts of the primary key.
Q.16. Write three conditions for second normal form.
Firstly, the primary key consists of only one attribute. Secondly, no non-key
attributes exist in the relation. Thirdly, every non-key attribute is functionally dependent on
full set of primary key attributes.
Q.17. What is transitive dependency?
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.18. When is a relation in 3NF?
A relation is in 3NF if it is in 2NF and no transitive dependency exists. The transitive
dependency is an important factor in normalization. A relation is not in 3NF if the value
of a non-key attribute can be obtained by knowing the value of another non-key attribute.

CH#5: Introduction to Microsoft Access


Short Questions
Q.1. What is MS Access?
Microsoft Access is a popular and powerful relational database management system. It
provides various built-in features to create database and view information. It can store and
process a large amount of data.

Q.2. What do you mean by IDE?


IDE stands for Integrated Development Environment. It provides different facilities to
create database applications easily. It is a graphical interface where the user can specify the
requirements for the database application.

Q.3. Write any four advantages of IDE.


It is easy to use. It simplifies the creation of database applications. It does not require a
detailed knowledge of databases. It provides predefined facilities to search, sort, retrieve and
process data in databases.
Q.4. What do you know about RDBMS?
RDBMS stands for relational database management system. It is a collection of programs
that are used to create and maintain relational databases. A database in which data is stored in
relations is called relational database.
Q.5. Define query.
A query is a statement that extracts specific information from database. Queries are used
to retrieve the required data from database. Data is retrieved according to the criteria given by
the user. It is a more flexible way of selecting, filtering and sorting records.
Q.6. Define form.
A graphical interface used to interact with the database is called form. It is used to enter,
retrieve, change, delete or update data in the database.
Q.7. Write any three advantages of forms.
Forms are easy to use. Forms use' graphical interface that is attractive. The user
can interact with database without technical knowledge.
Q.8. What are reports?
Reports are the outputs of database application. Reports are used to retrieve and present data
in a formatted way. The information on reports is arranged in different ways. A report may
also contain graphs, charts and tables etc.
CH#6: Table and Query
Short Questions
Q.1. List out five characteristics of a table.
The field of table contains a single value. The name of each field is unique. The order of
columns in the table is not important. The order of rows in the table is not important. A table
contains no duplicate records.
Q.2. Define the term degree of relation.
The number of fields in a relation is called degree of a relation. The degree of a table is
usually not changed once the table has been created. A table with five fields has a degree of 5.
Q.3. Define the term cardinality of a relation.
The number of records in a relation is called cardinality of a relation. The cardinality of
table changes as new records are added or existing records are deleted. A table with fifty
records has a cardinality of 50.
Q.4. Define sorting.
The process of arranging data or records in a sequence is known as sorting. The data can be sorted
in ascending sort or descending sort.

Q.5. Define filter.


A filter is used to extract the records that match a set of criteria. Filters are basically
Queries but they only appear to open tables or forms.
Q.6. Define referential integrity.
Referential integrity is a rule that preserves the defined relationship between the table
when records are added or deleted.
Q.7. What is a cross table query?
The cross-table query is used to calculate and restructure data for easier analysis. It
calculates a sum, average, count or other types of computation for data. These queries are
grouped by two types of information.
Q.8. What is a parametric query?
A parametric query displays a dialog box when it is executed. It gets some information
from the user as parameter. These queries are used as basis for creating forms and reports.

CH#8: Getting Started with C


Short Questions
Q.1. What is ANSI C?
The American National Standard Institute (ANSI) developed a standard version of the
language. The standard version is known as ANSI C.
Q.2. List any three characteristics of C language?
Three characteristics of C language include convenience, machine independence and
modularity.
Q.3. Define program.
A well-defined set of instructions given to the computer is called a computer program. A
computer program is written in a programming language.
Q.4. What is programming language?
A set of words and symbols used to write programs is called programming language. The
programming languages are used to write computer programs. A programming language is a
means of communication between a user and computer.
Q.5. Who develops computer programs?
A person who develops computer programs is called programmer. The programmer
develops programs to instruct the computer how to process data to convert into information.
Programmer uses programming languages or tools to write programs.
Q.6. Define low level language.
A language that is close to hardware and far from human language is called low level
language.
Q.7. What is assembly language?
Assembly language is a low-level language. It is one step higher than machine language, In
assembly language, machine instructions are replaced with English-like words known as
mnemonics.
Q.8. What is high level language?
A type of language that is close to human languages is called high level language the
instructions in these languages are similar to English' language such as input and print These
languages are easy to understand.
Q.9. What is meant by language processor?
Language processor or translator is software that converts the programs of high-level
languages into machine language. Every computer language has its own translators.
Q.10. What is a compiler?
A compiler is a program that converts the instruction of a high level language into
machine language as a whole. The machine code can be executed many times.
Q.11. How does a compiler work?
The compiler checks each statement in the source program and generates machine
instructions. Compiler also checks syntax errors in program. A source program containing an
error cannot be compiled.
Q.12. What is an assembler?
An assembler is translating program that translates the instruction of a assembly language
into machine language.
Q.13. Define source code.
A program written in a high-level language is called source code. It is also called source
program.
Q.14. Define object code.
A program in machine language is called object code. It is also called object program Computer
understands object code directly.
Q.15. What is the use of Turbo C++?
The compiler used for C language is Turbo C++. It is the implementation of Borland
International for C language. is used to create, edit and save programs. It also provides a powerful
debugger. The debugger helps users in detecting and removing errors in programs.
Q.16. What is the purpose of linker in C language?
The purpose of linker in C language is to combine the object program with additional library
files. Linker is part of compiler. It combines object program and library files and saves final
machine language program as executable file. The extension of executable file is .exe.
Q.17. What is preprocessor directive?
The preprocessor directives are commands that give instructions to C preprocessor.
The preprocessor directives are processed by a program called preprocessor, Preprocessor
directives start with hash symbol # and the keyword include or define. These directives are
written at the start of program.
Q.18. Give an example of preprocessor directive.
#include <stdio.h>
Q.19. How is a header file included in a C program?
The preprocessor directive include is used to add a header file in the program. The
name of the file is written in angle brackets < > after #include directive.
Q.20. What is the use of "include" preprocessor.
The "include" preprocessor directive enables a program to access a library. Each library
contains different header files. they include preprocessor directive is used to include header
files in the program.
Q.21. What is the use of "define" preprocessor.
The define directive is used to define a constant. It starts with the symbol #. It is not
terminated with semicolon. It can be used anywhere in the program.
Q.22. What are header files?
Header files are collection of standard library functions tb perform different tasks. Each
header file contains different types of predefined function. The extension of a header file is .h.
the include preprocessor directive is used to include header files in programs.
Q.23 What do you know about C statements?
A statement in C language is an instruction for the computer to perform a task. The
statement are written in curly brackets. Each statement in C is terminated with semicolon. The
compiler generates an error if any statements is not terminated by semicolon.
Q.24. Define the term bug and debug.
An error in a program is known as bug. The process of finding and removing bugs is
called debugging.
Q.25. What is a syntax error? Give example.
Syntax error is a type of error that occurs when an invalid statement is written in program.
Syntax errors are detected by compiler. A program containing syntax errors cannot be compiled
successfully. Typing 'for' instead of 'for' is an example of syntax error.
Q.26. list three causes of syntax error.
Firstly, the statement terminator may be missing at the end of statement. Secondly, a
misspelled keyword may be used in program. Thirdly, any of the delimiters may be missing.
Q.27. What are logical errors? Give Example.
A type of error that occurs due to poor logic of the programmer is known as logical
error. A statement with logical error may produce unexpected and wrong results in the
program. Typing a wrong formula to calculate the result is an example of logic error.
Q.28. What are run-time errors?
A type of error that occurs during the execution of program is known as run-time
error. It is caused when a statement directs the computer to execute an illegal operation
such as dividing a number by zero.
Q.29. What do you mean by delimiters?
The statements of a program are written in curly braces. The curly brace {is called
opening brace and} is called closing brace the brace are also known as Delimiters. These
statement are collectively known as the body of a program.

CH#9: Elements of C Language


ShortQuestions
Q.1 What is an identifier? Give some example of identifier.
The identifier is the name given to the variable, constants, type, function or label in the
program. It may consist of any number of characters. But the first 31 characters are significant
to C compiler. Some example of identifiers are student age item20and sum etc.
Q.2. What is standard identifier? Give some examples.
A type of identifier that has special meaning in C is known as standard identifier. C
cannot use a standard identifier for its original purpose if it is redefined. printf and scanf are
examples of standard identifiers.
Q.3. What is user-defined identifier? Give some examples.
The type of identifier that is defined by the programmer to access memory location
is known as user-defined identifier. The user-defined identifiers are used to store data
and program results. Some examples of user-defined identifiers are num, age, marks etc.
Q.4. What is keyword? Give some examples.
Keyword is a word in C language that has a predefined meaning and purpose. It
defined by the developer of the language. It cannot be changed or redefined by the user.
Some examples of keywords are if, while, int, and const.
Q.5. What is variable? Why is it used in programs?
A variable is a named memory location or memory sells. It is used to store program’s
input data and its computational result during execution. The value of variable may change
during the execution of the program. However, the name of variable cannot be changed.
Q.6. Define variable declaration
The process of specifying the variable name and its type is called variable declaration.
Q.7. Define variable initialization? How is a variable initialized?
The process of assigning a value to a variable at the time of declaration is known as
variable initialization. The equal sign = is used to initialize a variable. Variable name is
written on left side and the value is written on the right side of equal sign.
Q.8. What is garbage value?
The compiler automatically allocates the required memory for the variable when it is
declared. The memory location may already contain some data that is meaningless for the
program. This meaningless data is known as garbage value.
Q.9. Write any three rules for declaring variable in C.
The first character of variable must be a letter or underscore. The blank spaces are not
allowed in variable names. The reserved words cannot be used as variable names.
Q.10. What is the use of operators?
Operators are used to perform certain operations on data. For example, arithmetic
operators are used to perform arithmetic operators. The relational operators are used to by
compare values and logical operators are used to specify multiple conditions.
Q.11. List different types of operators in C.
Different types of operators in C are arithmetic, relational, logical, assignment increment,
decrement and compound assignment operators.
Q.12. Define compound assignment statement.
An assignment statement that assigns a value to many variables is as compound
assignment statement. The assignment operator = is used in this statement.
Q.13. What is the use of increment operator?
The increment operator is used to increase the value of a variable by 1. It is denoted by
the symbol ++. It is a unary operator and works with single variable.
Q.14. What is the use of decrement operator?
The decrement operator is used to decrement the value of a variable by 1. It is
denoted by the symbol--. It is a unary operator and work with single variable.
Q.15. Differentiate between unary and binary operators.
The unary operators work with one operand such as ++x. The binary operators work
with two operands such as x + y.
Q.16.What is relational operator?
The relational operators are used to specify conditions in programs. They compare two
values and produce result as true or false.
Example: The six relational operators in C language are >, <, ==, >=. <=, and !=.
Q.17. What is relational expression? Give some examples.
A type of expression that consists of constants, variables and relational operators is called
relational expression. These expressions are used to compare the values. Examples of
relational expressions are A>B, A<B, A<=B, A>=B, A==B and A!=B.
Q.18. What is compound condition? Give an example.
A type of comparison in which more than one conditions are evaluated is called At10
compound condition. It executes a statement or set of statements by testing many conditions.
An example of compound condition is (a > 50 && a < 100).
Q.19. What is the use of AND operator?
The symbol used for AND operator is (&&). It is used to evaluate two conditions. It
produces true if both conditions are true. It produces false result if any one condition is false.
Q.20. What is the use of OR operator?
The symbol used for OR operator is (l l). It is used to evaluate two conditions. It produces
true if either condition is true. It produces false result if both conditions are false.
Q.21. What is the use of NOT operator?
The symbol used for NOT operator is (!). It is used to reverse the result of a condition It
produces true result if the condition is false. It produces false result if the condition is true.
Q.22. What is expression?
A statement that evaluates €0 a value is called an expression. An expression gives
a single value. An expression consists of operators and operands. An expression may
consist of any number of operators and operands.
Q.23. Define type casting and its types.
The process of converting the data type of a value during execution is known as
type casting. Two types of casting are implicit type casting and explicit type casting.
Q.24. What are comments in C program?
Comments are the lines of program that are not executed. The complier ignores
comments and does not include them in executable program. That is why the comments
and does not include them in the executable program. That is why the comments do not
affect the size of executable program.
Q.25. How is implicit type casting performed?
Implicit type casting is performed automatically by the C compiler. The operands in
arithmetic operation must be of similar types. If the data types of operands are different, the
value with lower data type is converted into higher data type.
Q.26. How is explicit casting performed?
Explicit casting is performed by programmer. It is performed by using cast operator.
The cast operators tell the computer to convert the data type of a value.
Q.27. How are variables declared? Give two examples.
The variables in C language are declared by specifying the variable name and its data
type. Two examples of declaring variable are int marks; and float average;
CH#10: Input and Output
Short Questions
Q.1. Define standard input.
The process of giving something to computer is known as input. The input is mostly
given by keyboard. The term standard input refers to the input via keyboard.
Q.2. List some important functions for input.
scanf() gets() getch() getche()
Q.3. What is meant by Standard output?
The process of getting something from computer is known as output. The output is
mostly displayed on monitor. The term standard output refers to the output displayed on
monitor. The result of a program is the output of that program.
Q.4. What is the use of "scanf" function? Write its syntax.
The scanf function is used to .get input from the user. The input is stored in a variable
The syntax of scanf function is as follows:
scanf(control string, &variable, &variable2, &variable3...);
Q.5. What is the use of "printf" function? Write its syntax.
The printf function is used to display outpUt on the monitor. It can display constants or
values of variables on screen in specified format. The' syntax of printf function is printf
(Format String, argument list);
Q.6. What is use of format specifiers in C language?
Format specifier is used to specify the format according to which values will be read d
displayed. It determines the data type of variable, field width and format of the value.
Q.7. Name six escape character provided by C
Six escape sequences used in C language are \a, \b, \f, \n, \r, and \t.
Q.8. What is the use of "getch" function?
The getch( ) function is used to input single character from user. It is an abbreviation
of "get character". When it is executed, the character entered by user is not displayed on
screen.
Q.9. What is the use of "getche" function?
The getche function is used to input single character from user. It is an abbreviation of
"get character". When it is used, the character entered by the user is displayed on the screen.
Q.10. Differentiate between printf and scanf functions.
The printf function is used to display different values on the screen. It can display text,
constant or values of variables in specified format. The scanf function is used to get different
types of inputs from the user. The input is stored in variables in specified format.
Q.11. Differentiate between gets and puts functions.
The gets function is used to input string values from the user. The input is stored in.a
string variable. The puts function is used to display string values on the screen. It can display
string constant or string Variable.

Ch# 11: Decision constructs


Short Questions
Q.1. What is control structure?
A statement used to control flow of execution in a program or function is called control
structure. The control structures in C are used to combine individual instruction into a single
logical unit. The logical nit has one entry point and one exit point.
Q.2. Define flowchart.
A flowchart is the graphical representation of a program.

Q.3. What is a condition?


A condition is an expression that evaluates to true (I) or false (O).

Q.4. What do you know About "if" statement?


if is a keyword in C language. if statement is a decision-making statement. It is the simplest
form of selection constructs. It is used execute or skip a statement or set of statement by
checking condition.
Q.5. Define compound statement.
A set of statements written in curly brackets { } after if statement is called compound
statement.
Q.6. What is the use of "if-else" statement?
If else statement is another type of if statement. It executes one block of statement(s) when
the condition is true and the other when it is false. In any situation, one block is executed
and the other is skipped.

Q.7. Write the syntax of "if-else" statement'.


If (condition)
statement;
else
statement;

Q.8. What is the use of "if-else-if" statements?


If-else- if statement can be used to choose one block of statement from many blocks of
statements. It is used when there are many options and only one block of statements should
be executed on the basis of a condition.

Q.9. What is "switch" statement?


The switch statement is used easily when there are many choices and only one should be
executed. The switch construct is useful in the cases where selection is based on the value.

Q.10. Write the alternative of if-else statement in C.


Conditional operator is an alternative of if-else statement in C. It is a decision-making structure
at is also called ternary operator as it uses three operands.

Ch#12: Loop Constructs


Short Questions
Q.1. Define loop.
A statement or number of statements that are executed repeatedly is known as loop.

Q.2. Write two uses or advantages of loops.

Loops are used to execute a statement or number of statements for a specified number of times. Loops
are used to access a sequence of values.

Q.3. What is "while" loop?


"while" loop is the simplest loop of C language. It executes one or more statements while the given
condition remains True. It is useful where the number of iterations is not known in advance.
Q.4. What do you know about do-while loop?
The do-while is an-iterative control in C language. It executes one or more statements while the given
condition is' true. The condition in this loop checked after the body of loop That is why it is executed at
least once.

Q.5. Write the syntax of while loop with example.


while (Condition)
statement(s);
Example int count = 0;
while (count < 10)
{
Printf("Programming");
count++
}

Q.6. Write the syntax of do-while loop with example.


do
{
statement1;
statement2;
:
statement N;
}
while (condition);
Example
int n = 4;
do
{
n=n*3
}
while (n <= 100);

Q.7. Write the syntax of do-while loop with example.


The syntax of this loop is as follows:
for (initialization; condition; increment/decrement)

{
statement 1;
statement 2;
:
statement N;
}
Example
int i, n = 4;
for(i = n; i >= 0; i--)
printf(“Pakistan”);
Q.8. What is "for" loop?
For loop executes one or more statements for a specified number of times. This loop is also
called counter-controlled loop. It is the most flexible loop. That is why the most programmer
use this loop in programs

Q.9.What is counter-controlled loop?


The counter-controlled loop depends on the value of a variable known as counter variable. The
value of counter variable is incremented or decremented each time the body of loop executes.
The loop terminates when value of counter variable reaches a particular value.

Q.10.What is nested loop? How does it work?


A loop Within a loop is called nested loop. In nested loops, the inner loop is executed completely
with each change in the value of counter variable of outer loop. Any loop can be used as inner loop
of another loop.

Q.11. Define infinite loop.


A loop in which the ending condition never occurs is called infinite loop. It repeats forever until the
user intervenes to stop the loop.

Q.12. What is the use of "goto" statement?


The goto statement is used to perform an unconditional transfer of control to a named label. The
label must be in the same function. A label is meaningful only to a goto statement.

Q.13. What is post-test loop?


A posttest loop is type of loop in which the condition is checked after executing the body of the loop.
It means that the statements in the loop will be executed at least once.
Ch#13: Function in C
Short Questions

Q.1. What is function?


A function is a named block of code that performs some action. The statements is written in a
function are executed when it is called by its name.
Q.2. Why is function used in a program?
The real reason of using functions is to divide a program into different parts. These parts of a
program can be managed easily.

Q.3. List different types of functions in C.


C language provides two types of functions. These are user-defined functions and built-in
functions.
Q.4. What do you know about user-defined functions?
A type of function written by the programmer is known as user-defined function. User-defined
function has a unique name. A program may contain many user-defined functions. These
functions are written according to the exact need of the user.

Q.5. Define function header.


The first line of a function definition is known as function header. The function header consists
of return type, function name and parameters.

Q.6. Define function body.


The set of statements which are executed inside the function is known as function body. The
body of function appears after function header. The statements are written in curly braces { }
The variable declaration and program logic are implemented in function body.
Q.7. What is a function call?
The statement that activates a function is known as function call. A function is called with its
name. Function name is followed by necessary parameters in parentheses. If there are many
parameters, these are separated by commas.
Q.8. How does a function return value?
A function returns single value. The return type in function declaration indicates type of value
returned by function. return keyword is used to return a value to calling function.
Q.9. What is the use of parameters in functions?
The parameters used in function call are called actual parameters. These parameters function are
used to send values to function. The parameters in function declaration are called formal
parameters. These parameters are used to receive values from calling function.

Q.10. Define local variable.


A variable declared inside a function is known as local variable. Local variables are also called
automatic variables.
Q.11. What is meant by the scope of local variable?
The area where a variable can be accessed is known as scope of variable. Local variable can
be used only in the function in which it is declared. If a statement accesses a local variable
that is not in scope, the compiler generates a syntax error.

`Q.12. Compare local and global variable.


Local variables are declared in a function but global variables are declared outside any
function. Local variable is created when the control enters the function but global variable
is created when the program starts.

Q.13. How is a function activated?


• The function is activated by using a statement known as function call. A function is called
with its name. Function name is followed by necessary parameters in parentheses. If there are
many parameters, these are separated by commas. If there is no parameters, empty parentheses
are used.

Ch#14: Function in C
Short Questions
Q:1 What is pointer? Also write example.
Q:2 What is EOF?
Q:3 What is Stream?

You might also like