Hyperlink 10 Answer Keys

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

CLASS· X

CH-1 SOCIAL IMPACTS OF IT


A. Fill in the blanks:
1. Passwords, Pin Numbers
2. Virus
3. Worm
4. Crackers
5. Spam
6. Client, Server
7. Spammer
8. Key Loggers
9. Decryption
10. White Hat
B. State True or False:
1. True
2. True
3. True
4. False
5. False
6. True
7. True
8. True
9. True
10. True
C. Multiple Choice Questions:
1. (c) Vital Information Resources Under Seize
2. (c) Stone virus
3. (c ) Web hijacking
4. (c ) Ankit Fadia
5. (c ) Spyware
6. (b) Antivirus
7. (c) Hackers
8. (b) Backup
D. Answer in one word or sentence:
1. Mail Bombing
2. Stealth Virus
3. Richard Skrenta
4. Antivirus
5. Backup
6. Encryption

E. Answer the following:


1. A virus is a set of programs that disrupts the normal functioning of a computer. It enters into the computer without
any knowledge of the user and infects and destroys the data. The types of viruses are:
a) Boot virus: This type of virus infects the boot records which are responsible for loading the operating system in the
memory of computer. This gets active at the time of booting the machine. For example: Disk killer and Stone virus.
b) Program file virus: These viruses infect the executable files or programs with extension .com, .exe, .sys, etc. They
become active in memory by replicating itself and infecting files on the disk. For example: Sunday and Cascade.
2. The functions of antivirus software are:
a) It scans the computer files and e-mails to look for viruses.
b) It identifies the suspicious behaviour of the computer programs.
c) It prevents and removes viruses from the computer.
3. Firewall is a software or hardware tool that protects a server, a network or a PC from almost every attack by viruses
and hackers.
4. Spams are unwanted e-mails that come from strange sources. These are generally sent in large number for commer­
cial advertising. Millions of copies of the same message are sent to e-mail users worldwide.
5. Hackers and crackers both explore computers, access data and applications without owner's permission. But hackers
do it for both ethical and non-ethical purposes, whereas crackers are always destructive.
6.Recovery utilities are used to restore data from logical damage.They recover every readable bit from the surface and
recover logical file structure of the storage media.Some of the recovery utilities are PhotoRec, Recuva, Adroid Photo
Recovery.
7. The various security provisions in E-commerce are:
a) Privacy using encryption: To ensure data security, it is transformed into unreadable code through the encryption
process.
b) Passwords and Pin numbers: To protect data and important information, unique passwords and Pin numbers are
given to every user. It protects our data from unauthorized access.
c) Firewalls: These are software or hardware tools that protect a server, a network or a PC from almost every attack by
viruses and hackers.
8. A Worm is considered to be a sub-class of a virus. It has the capability to replicate itself on a system and causes the
huge devastating effect. Due to its copying nature, it results into heavy consumption of the system memory.
9.Trojan horse is a program that appears to be useful, but actually damages the computer once it is installed.This virus
irritates the user by changing the desktop and adding silly desktop icons. Sometimes, it can cause serious damage by
deleting files and destroying information.
10. A virus can cause the following problems:
a) It decreases the speed of the computer by decreasing the memory.
b) It displays unusual messages on the screen.
c) It reformats the hard disk and deletes / damages the files.
d) It displays a change in data against the filename in the directory.
11. Backup is the process of making duplicate copies of data, which can be used to restore the original data in case of
any data loss event. Regular data backup is very important practice.The techniques of data backup are:
a) Offline backup: In this system, users attach a storage media to a computer and copy files.
b) Online backup: Such systems can be seen in big organizations that send copy of the fresh data to their database
servers frequently.This way they can get a copy of every piece of important data anytime, in case of data loss.

CH-2 ALGORITHM AND FLOW CHART


A. Fill in the blanks:
1. Algorithm
2.Sequence
3. Flowcharts
4. Maintenance
5. Program Logic
6. Complex
7. Decision

B. State True or False:


1. True
2. False
3. False
4. True
5. False
6.True
7. False

c. Multiple Choice Questions:


1. (a) Programmer
2. (b) Flow lines
3. (a) Input/Output box
4. (c) Start/Stop box
5. (c) Three
6. (c) Repetition construct
D. Answer in one word or sentence:
1. Program or Programming statements.
2. GD show symbol of connector here
3. Input/ Output box
4. Decision box
5. Processing box
E. Answer the following:
1. The step by step procedure to solve any logical and mathematical problem is called algorithm. Its characteristics are:
a) An algorithm should have finite number of steps to reach to a solution.
b) Each instruction should be written in a simple and precise manner.
c) After the instructions are executed, the user must get the desired result.
2. In order to ensure that program instructions are written correctly and in a proper sequence, programs must be
planned before they are written. Otherwise, computer will produce wrong result.
In problem solving, an algorithm can perform the following tasks:
a) The problem is reduced into a series of small steps.
b) Every step can be easily debugged.
c) Decision making becomes more rational.
3. Three types of constructs are used in developing an algorithm:
a) Sequence construct: It is a series of steps that get executed in the sequence they are written.
b) Decision construct: It define one or more courses of action based upon a condition, which produces result in the
form of true or false.
c) Repetition construct: It allows one or more statements to be repeated as long as a given condition is true.
4. A flowchart is a pictorial representation of steps used to solve a particular problem. It uses different shapes or sym­
bols to represent different types of instructions. The various symbols are:
a) Start/ Stop box
b) Input/ Output box
c) Processing box
d) Decision box
e) Flow lines
f) Connectors
5. The advantages of flowchart are as follows:
a) It is easier for the programmer to explain the logic of the program.
b) Pictorial representation helps to analyze the problem in detail.
c) It is helpful in detecting, locating, and removing the mistakes from the program.
d) Flowcharts act as a roadmap that gives clear idea to the programmer to write a program.
CH- 3 INTRODUCTION TO C
A. Fill in the blanks:
1. At&t Bell
2. Preprocessor
3. Main( )
4. Constants
5. Real
6. Keywords
7. Identifiers
8. Statement
9. Link Section
10. Token

B. State True or False:


1. False
2. False
3. True
4. False
5. True
6. False
7. True
8. True
9. True
10. True
C. Multiple Choice Questions:
1. (a) Dennis Ritchie
2. (c) Compiler
3. (b) String
4. (a) Case sensitive
5. (b) Control
6. (a) Expression
7. (a) Standard input output header file
8. (a) Semicolon
D. Answer in one word or sentence:
1. C99 is the latest version of C language.
2. Keywords are predefined by software developer for some specific reason.
3. Declaration part
4. printf() command is used to print any message on the screen.
5. Program execution begins with the main() function.
6. Hash (#) symbol is used to link functions from the system library.
E. Answer the following:
1. C is called as a middle level language as it combines the capability of an assembly language with the features of high
level language. The features of C language are:
a) It is a robust language. It has a rich set of built-in functions and operators.
b) It is highly portable. C programs written for one computer can be run on another.
c) C has the ability to extend itself i.e., we can add our own functions to its existing library.
d) Programs written in C are efficient due to its variety of data types and powerful operators.
2. Character set is a list of characters that a language can recognize. C character set includes alphabets, digits, special
symbols, etc.
3. Keywords are the reserved words in programming which are predefined by the software programmer and have fixed
meaning. C has 32 keywords. For example: int, char, else, etc.
4. Two types of constants are used in C language:
a) Numeric constants: These values can be integers or real numbers. For example: -1234, 75, 5.67, 45.784, etc.
b) Character constants: These can be single character or multiple characters. For example: 'p', '56', "Programming",
"Computer", etc.
5. Identifiers are the names given to C entities, such as variables, functions, and structures, etc. These are user defined
names. For example, int sum; int result;
6. There are four types of instructions in C language:
a) Type declaration: It is used to declare the type of variables.
b) Input/ Output: It is used to input data to a program and obtaining the output from it.
c) Arithmetic: It is used to perform arithmetic operations between constants and variables.
d) Control: It is used to control the sequence of execution of various statements in the program.
7. The structure of C program consists of various sections as given below:
Documentation section
Link section
Global declaration
main( )
{
Declaration section Body of the main( ) function
Executable part
}
Subprogram section
Function 1
Function 2

Function n

8. A statement causes the computer to carry out some definite action. There are three types of statements in C :
a) Expression statement: It consists of an expression followed by a semicolon. For example, c =a+ b;
b) Control statement: It enables you to execute the particular set of statements depending on a condition and controls
the flow of a program.
c) Compound statement: It consists of several individual statements enclosed within a pair of brackets.
LAB ACTIVITY
1. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Welcome to the world of computers");
getch();
}
2. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Name : Kritika ");
printf("Class : X ");
printf("Roll_No : 4 ");
printf("Age : 15");
getch();
}
3. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
printf("Be Good and Do Good \n");
printf("\n");
getch();
}
4. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Failures are the Pillars of Success");
getch();
}
CH-4 DATA TYPES AND OPERATORS
A. Fill in the blanks:
1. Expression
2. Variable
3. Postfix Decrement
4. Syntax
5. Two
6. True
7. Ternary Operator
8. Float
9.15
B. State True or False:
1. True
2. False
3. False
4. False
5. True
6. False
7. True
C. Multiple Choice Questions:
1.(c) Operators
2.(a) Data type
3.(a) 2 or 4
4.(b) Assignment
5.(a) Unary
6.(b) Arithmetic
7.(a)%
8.(a) Relational
9.(a) &&
10.(a) String
D. Answer in one word or sentence:
1. 8 bytes
2. 6 decimal places
3. Six operators
4. False
5. 6
6. False
7. 1 byte
E. Answer the following:
1. Data types are defined as the data storage format that a variable can store to perform a specific operation. The size
of a variable and constant are determined by data types. They are classified as
a) Primitive data types b) Derived data types
2. The basic data types available in Care:
a) int: Integer data type is used to store whole numbers. It can store both positive and negative numbers. Its size is 2
or 4 bytes.
b) float: It can hold real numbers, such as 2.321, -9.654, etc. Its storage size is 4 bytes and it has a precision of 6 decimal
places.
c) double: It is similar to float data type. The only difference is that its storage size is 8 bytes and precision up to 15
decimal places.
d) char: This data type can store either a single character or a combination of characters called string. Its storage size
is 1 byte.
3. Variable declaration:
The syntax of declaration of a variable is:
<Data type><variable_name>;
For example, the statement
int age ;
Will declare the variable age with data type int.
Initialization:
Assignment operator(=) is used to initialize a variable. For example, int age = 15;
The above statement declares an integer type of variable age and initializes it with value 15.
4. Float and double data types are used to store decimal values. But they differ from each other in terms of their sizes
and precision values. Float data type has size of 4 bytes and precision up to 6 decimal places, whereas double data type
has size of 8 bytes and precision up to 15 decimal places.
5. Operators are the special symbols that perform specific operations on one, two or more operands, and give mean­
ingful result. Cprovides us a large number of operators to perform arithmetic and logical calculations easily.
6. An expression is a valid combination of operators and operands, which returns computed result. Some of the exam­
ples of expression are:
a) x = 8 * 4; b) c = a+ b/2; c) w = x + y + z ;
7. Ternary operator works on three operands. It is also known as conditional operator. Its syntax is:
Variable = Expression 1? Expression 2: Expression 3 ;
If Expression 1 is true then the Expression 2 will be evaluated and assigned to the Variable, otherwise, Expression 3 will
be evaluated and assigned to the Variable.
8. If we use ++ as prefix(++var), the value of operand is increased by I and then it is returned. Whereas, if we use ++
operator as postfix(var++), the value of operand is returned first and then it is incremented by 1.
9. Relational operators are used to compare two operands and determine the relation between them. It gives result in
two states either true or false. Cprovides 6 relational operators. These are:
a) Greater than( > ) b) Less than( < ) c) Greater than or equal to( >=)
d) Less than or equal to(<=) e) Equal to(==) f) Not equal to(!= )
10. Logical operators are used for logical operations, which compare the result of relational expressions and give result
in the form of true or false. C provides three logical operators.
a) AND(&&) b) OR (11) c) NOT(!)
LAB ACTIVITY
1. #include<stdio.h>

#include<conio.h>
void main()
{
int p=200000, t=4;
float r=2.5;
float si=p*r*t/100;
clrscr();
printf("Simple interest = %f", si);
getch();
}
2. #include<stdio.h>

#include<conio.h>
void main()
{
int n1=34,n2=12,n3=23;
int sum=0;
float avg=0;
sum =nl+n2+n3;
printf(" Sum of three numbers = %d", sum);
avg = sum/3;
clrscr();
printf("Average of three numbers = %f", avg);
getch();
}
3. #include<stdio.h>
#include<conio.h>
void main()
{
int 1=5,b=7;
int area=l*b;
clrscr();
printf("Area of rectangle is %d",area);
getch();
}
4. #include<stdio.h>

#include<conio.h>
void main()
{
float salary = 30000;
float incre = 0;
float total_salary = 0;
clrscr();
incre= salary*lS/100;
total_salary=salary+incre;
printf("Salary after increment %f",total_salary);
getch();
}

5. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=40,b=5;
int c=a/b;
int d=a%b;
printf("\n Quotient = %d", c);
printf("\n Remainder = %d", d);
getch();
}
6. #include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=lO, b=12;
int c=a;
a=b;
b=c;
printf("After swapping");
printf("\n a = %d",a);
printf("\n b = %d",b);
getch();
}

CH- 5 INPUT OUTPUT INC


A. Fill in the blanks:
1. Getch()
2. Printf()
3. Header Files
4. Scanf()
5. Getchar(), Putchar()
6. Gets()
B. State True or False:
1. False
2. True
3. True
4. True
5. False
6. False
C. MultipleChoice Questions:
1. (a) Standard input/output header file
2. (a) float
3. (b) Output
4. (a) Console input/output header file
5. (a) Format specification
6. (b) conio.h
D. Answer in one word or one sentence:
1. <stdio.h> header file is used for input/output statements.
2. h stands for Header file in the <stdio.h>.
3. clrscr() function is used to clear the previous output.
4. Ampersand (&) symbol is used to get the address of a variable from the memory.
5. gets() function.
6. getchar().
7. puts() is used to print the string on the screen.
E. Answer the following:
1. Input/ Output functions are used to enter data from an input unit such as keyboard and to get the result on the
output unit such as monitor. These functions can be included in the program by using <stdio.h> header file. The most
commonly used 1/0 functions are:
a) printf( ) b) scanf( ) c) getchar( ) d) putchar( )
2. The printf( ) function starts examining the written data from left to right. It continues displaying the characters on to
the screen. The moment it finds the symbols, such as escape sequences (In) or format specifications {%f), it takes an
appropriate action and continues the process till it reaches to the end.
3. Format specifications are the symbols that are used along the printf ( ) function.These tell the C compiler about how
the data should be represented, stored, or displayed. For example, %d and %f are used to display integer and float type
variables respectively.
4. The scanf ( ) function is used to read data from the keyboard and store it in the memory that can be formatted in a
certain way.
5. The putchar( ) function is used for writing characters one at a time on the screen. Whatever character is passed
through getchar( ) function can be displayed on the screen with the help of putchar( ).
6. The getch( ) function gets a character from the keyboard but does not echo to the screen. Whereas, the getche( )
function echoes the character that you have typed on the screen so that you can see what you have typed last.
LAB ACTIVITY
1.
#include<stdio.h>
#include<conio.h>
void main()
{
int a=O,b=O;
int c=O;
printf("Enter two numbers \n" );
scanf("%d",&a);
scanf("%d",&b);
c=a*b;
printf("Product of two numbers= %d",c);
getch();
}

2. #include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two numbers \n" );
scanf("%d",&a);
scanf("%d",&b);
clrscr();
printf("First number %d",a);
printf("\n" );
printf("Second number %d",b);
getch();
}

3.
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter a number or a character \n" );
ch=getchar();
printf("Printing value using putchar() \n" );
putchar(ch);
getch();
}

4.
#include<stdio.h>
#include<conio.h>
void main()
{
char a, b;
printf(" Using getch() \n");
printf(" Press any key \n");
clrscr();
a=getch();
printf("Pressed key is not visible \n");
printf(" Using getche() \n");
printf(" Press any key \n");
b=getche();
printf("\n Pressed key is visible \n");
getch();
}

SAMPLE PAPER- I
A. Fill in the blanks:
1. Comment lines
2. Algorithm is a
3.Sequence
4. Token
5. main()
6.Syntax
7. True
8. getch()
9. Passwords, Pin numbers
10. gets( )
B. State True or False:
1. False
2. False
3. True
4. False
5. True
6. True
7. True
8. True
9. True
10. False
C. Multiple Choice Questions:
1. (a) Start/ Stop
2. (a) Dennis Ritchie
3. (a) 2 to 4
4. (a) Conversion specification
5. (c ) Spyware

D. Answer in one word:


1. Program
2.Standard Input/Output Header file
3. Decision box is used to check or apply any condition in a program.
4. Processing box is used for writing processing instructions in a program.
5. Hash (#)
6. The result will be False.
7. getchar()
8. Double type data takes 8 bytes in the memory.
9. Declaration part
10. Encryption
E. Answer the following:
1. In order to ensure that program instructions are written correctly and in a proper sequence, programs must be
planned before they are written. Otherwise, computer will produce wrong result.
In problem solving, an algorithm can perform the following tasks:
a) The problem is reduced into a series of small steps.
b) Every step can be easily debugged.
c) Decision making becomes more rational.
2. Data types are defined as the data storage format that a variable can store to perform a specific operation. The size
of a variable and constant are determined by data types. They are classified as
a) Primitive data types b) Derived data types
3. If we use ++ as prefix (++var), the value of operand is increased by I and then it is returned. Whereas, if we use ++
operator as postfix (var++), the value of operand is returned first and then it is incremented by 1.
4. Identifiers are the names given to C entities, such as variables, functions, and structures, etc. These are user defined
names. For example, int sum; int result;
5. Character set is a list of characters that a language can recognize. C character set includes alphabets, digits, special
symbols, etc.
6. The various security provisions in E-commerce are:
a) Privacy using encryption: To ensure data security, it is transformed into unreadable code through the encryption
process.
b) Passwords and Pin numbers: To protect data and important information, unique passwords and Pin numbers are
given to every user. It protects our data from unauthorized access.
c) Firewalls: These are software or hardware tools that protect a server, a network or a PC from almost every attack by
viruses and hackers.
7. These are software or hardware tools that protect a server, a network or a PC from almost every attack by viruses
and hackers.
8. The scanf() function is used to read data from the keyboard and store it in the memory that can be formatted in a
certain way.
F. Give the full forms of the following:
1. VIRUS:Vital Information Resource Under Seize
2. UDP: User Datagram Protocol
3. BCPL: Basic Combined programming Language
4. ANSI: American National Standards Institute
G. Write short notes on the following:
1. Antivirus: These are computer programs which are designed to identify, prevent, and remove viruses from the com­
puter.
2. Input/ Output functions: These are used to enter data from an input unit such as keyboard and to get the result on
the output unit such as monitor. These functions can be included in the program by using <stdio.h> header file. Com­
monly used 1/0 functions are printf ( ), scanf ( ), getchar ( ), putchar ( ) etc.

CH- 6 CONDITIONAL CONTROL STRUCTURES


A. Fill in the blanks:
1. Decision
2. Two
3. Switch
4. Break
5. Branching, Looping
6. Nested if
B. State True or False:
1. False
2. True
3. True
4. True
5. True
6. False
7. False
C. Multiple Choice Questions:
1. (b) Bi-directional
2. (b) Curly braces
3. (a) Default
4. (c) Is compulsory to be used in a switch statement.
5. (d) Switch
6. (b) Break
7. (a) Alt+F+O
D. Answer in one word or sentence:
1. Break statement takes the program control out of the program.
2. Switch statement can be used to check multiple conditions.
3. Compound statements
4. If control and Switch case statements
5. Relational operator is used for making two way decisions.
E. Find out errors, if any:
1. Remove semicolon after the statement if a>lO;
2. Remove round braces after the break ( ); statement
3. Replace the word 'zero' with the number O in the statement if (b > zero)
F. Answer the following:
1. Conditional control structures allow the programmer to control the flow of execution of statements based upon dif­
ferent conditions. These statements decide what action is to be taken and execute the set of instructions accordingly.
2. The if-else control structure is a branching statement. It is a logical situation where either of the two actions are to
be performed depending upon the certain condition. If the condition is true then if block gets executed. Otherwise,
else block gets executed.
3. The if-else statement is a two way branching statement, whereas if else if has a ladder of if else constructs. When
the expression in the 'if condition' is false, another if else construct is used to execute a set of statements based on the
condition. The following example...............
4. The Switch case control structure is used when there is a requirement to check multiple conditions in a program. It
allows a variable to be tested for equality against a list of cases. When one value matches the value of the variable, the
computer continues executing the program from that point. If none of the cases matches, the compiler executes the
default statement.
5. The default case gets executed when the value of the given variable does not match with any of the case value.
6. (a) Compound statement: A sequence of statements enclosed within a pair of braces is called a compound state­

t
ment. For example:
int a=8, b =7, c =9 ;
( a> b)

int d = a + b+ c ;
Printf("%d", d) ;
a++; Compound statement
b--;
}
b) Break statement: This statement is used to bring the control out of the switch expression. It should be written with
every case. If we do not write break statement at the end of each case then all the subsequent cases will get executed.
The following segment explains the use of break statement:
int ch=2;
switch( ch)
{
easel:
printf("\n Color is red" );
break;
case 2:
printf("\n Color is green");
break;
case 3:
printf("\n Color is blue");
break;
}
LAB ACTIVITY
1.
#include<stdio.h>
#include<conio.h>
void main()
{
int a=15,b=90,c=10;
clrscr();

if(a>=b && a>=c)


printf(" Largest number is %d ",a);
if(b>=c && b>=a)
printf(" Largest number is %d ",b);
if(c>=a && c>=b)
printf(" Largest number is %d ",c);
getch();

2.
#include <stdio.h>
#include<conio.h>
void main()
{
int n, i, flag=O;
printf("Enter a positive integer: ");
scanf{"%d",&n);
for(i=2;i<=n/2;++i)
{
if{n%i==O)
{
flag=l;
break;

}
if (flag==O)
printf{"%d is a prime number.",n);
else
printf{"%d is not a prime number.",n);
getch();
}

3.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a=1,b=4,c=2,d;
float r1,r2;
d=b*b-4*a*c;
clrscr();

if(d>=O)
{
rl={-b+sqrt(d))/(2*a);
r2={-b-sqrt(d))/(2*a);
printf("\n Rootl = %f",r1);
printf("\n Root2 = %f",r2);
}
else
printf("\n Roots are imaginary");
getch();
}

4.
#include <stdio.h>
#include <conio.h>
void main()
{
char n;
printf("Enter the value");
scanf("%c",&n);
switch(n)
{
case'-':
printf("You entered negative.");
break;
case'O':
printf(" number is zero.");
break;
default:
printf("number is positive ");
break;
}
getch();

5.
#include<conio.h>
#include<stdio.h>
void main()
{
int x,y,z;
printf("\n Enter the sides of a triangle");
scanf("%d %d %d",&x,&y,&z);
if ((x==y) && (y==z))
printf("\n The triangle is equilateral");
else if ((x==z) 11 (y==z) 11 (x==y))
printf("\n The triangle is isoseles");
else
printf("\n The triangle is scalene");
getch();
}

6.
#include<stdio.h>
#include<conio.h>
void main()
{

char c;
printf("Enter character \n");
scanf("%c", &c);
clrscr();
switch(c)
{
case'a':
case'e':
case'i':
case'o':
case'u':
printf("lts a vowel");
break;
default:
printf("lt is not a vowel ");
break;
}
getch();
}
CH- 7 LOOPING CONTROL STRUCTURE
A. Fill in the blanks:
1. Three
2. Initial
3. Statements
4. Label
5. Exit control
6. Jump
7. For
B. State True or False:
1. False
2. False
3. True
4. True
5. False
6. True
7. True
8. False
9. False
10. True
C. Multiple Choice Questions:
1. (b) Looping
2. (c) Nested
3. (c) do while
4. (b) for
5. (a) Step value
6. (b) break
7. (a) Loop
8. (c) Jumping
9. (a) Continue
D. Answer in one word:
1. Double quotes of format specification in printf statement are missing.
2. printf statement is missing.
3. In for statement, semicolon (;) after a<lO is missing. And wrong format specification is given in printf statement.
4. Increment step is missing.
E. Answer the following:
1. Looping control structure has a condition and a block of statements. Till the time the specified condition remains
true the compiler keeps executing the loop i.e., the statements are written in its body.
2. The for loop is used to repeat a particular task finite number of times. It executes a set of statements only after the
condition evaluates to true.
3. The while loop tests the condition before executing the loop body. When the condition becomes false, the control
comes out of the loop. On the other hand, do while loop first executes the block of statements and then checks the
condition. The body of the loop gets executed at least once even if the condition is found false.
4. A loop written inside another loop is called a nested loop. The inner loop gets executed first and then the outer loop
executes. The following example explains the use of nested loop:
(GD Pick program 8 page no. 70)
5. Break statement is used to terminate the execution of the current loop and the control comes out of the loop,
whereas the continue statement skips the next statement and takes the control to the header of the loop.
6. The goto statement is used to change the normal sequence of program execution by transferring the control to some
other part of the program unconditionally.
LAB ACTIVITY
1.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,d,p;
printf("Prime numbers are ");
for(n=2;n<=S0;n++)
{
for(d=2;d<n;d++)
{
if(n%d==0)
{
p=0;
break;
}
p=l;
}
if(p)
printf("\t%d",n);
}
getch();
}

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

void main ()
{
float i= 10, s = 0.0;
for (i=l; i<=4; i++)
s = s + 1/i;
printf("Sum is %f", s);
getch();

3.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter the number \n");
scanf("%d",&n);
printf(" Reverse of the number is ");
while(n>0)
{
int m=n%10;
printf("%d",m);
n=n/10;
}
getch();
}

4.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();

for(i=l; i<=100;i=i+2)
{
printf("\t %d",i);
}
getch();
}

5.
#include<stdio.h>
#include<conio.h>
void main()
{

int n,sum=O;
n=l;
printf("Natural numbers are \n");


clrscr();
while(n<=lO)
{
printf("\n %d",n);
sum=sum+n;
n++;
}
printf("\n Sum of 10 natural numbers = %d",sum);
getch();
}

6.
#include <stdio.h>
#include<conio.h>
void main()
{
int i, numl, num2, min, hcf=l;
printf("Enter any two numbers to find HCF: ");
scanf("%d %d", &numl, &num2);
min = (numl<num2) ? numl: num2;
for(i=l; i<=min; i++)
{
if(num1%i==O && num2%i==O)
{
hcf = i;
}
}
printf("HCF of %d and %d = %d\n", numl, num2, hcf);
getch();
}

7. Generate the following pattern:


a)#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,n;
for(i=l;i<=6;i++)
{
printf("\n");
for(j=l;j<=4;j++)
printf("*");
}
getch();
}

b) #include<stdio.h>
#include<conio.h>
void main()
{

int a=l, i;
clrscr();
for( i=0;i<=4;i++)
{
if(a==l)
{
printf("\n %d",a);
a=ll;
}
if(a<=14641)
{
printf("\n %d",a);
a=a*ll;
}
}
getch();
}

c) #include<stdio.h>
#include<conio.h>
void main()
{

int i,j,n;
clrscr();
for(i=l;i<=S;i++)
{
printf("\n");
for(j=l;j<=(2*i-l);j++)
printf("*");
}
getch();
}

CH- 8 FUNCTIONS IN C
A. Fill in the blanks:
1. Function definition
2. Built-in
3. Program control
4. Parameter
5. Call by value
6. Empty
7. Argument
8. Formal parameters, Actual arguments
B. State True or False:
1. False
2. False
3. True
4. True
5. True
6. False
7. False
8. True
C. Multiple Choice Questions:
1. (a) Input
2. (b) Buitl-in
3. (b) User defined
4. (a) Body
5. (a) Recursion
6. (b) Return type
7. (a) Actual parameters
D. Answer in one word or one sentence:
1. Only one return statement gets executed.
2. Formal parameters
3. Call by reference
4. Call by value
5. There are two ways of calling the function.

E. Answer the following:


1. A function is a block of code that can be reused anywhere in the program. It divides the program in smaller modules,
thus making it easier to read and debug.
2. Functions are of two types:
a) Library or built-in functions: These functions are grouped together and stored in C library. They perform the basic
1/0 and mathematical operations.
b) User defined functions: These functions are designed by the user to carry out some specific tasks as per the need in
the program.
3. C compiler starts executing the program from the main ( ) function. During execution, whenever a function is called
by its name, the program control finds the function and executes its statements. Then program control automatically
comes back to the location from where the function was last called.
4. Return type of a function specifies the data type of the result that will be returned by the function. Return statement
is used to send back the result of the executed statements to the place where the call is made.
5. Function body contains the block of statements within curly braces, which are used to carry out some actions. These
statements get executed when function is called in a program.
6. A function prototype is the first line of function definition. It gives information to the compiler about the function
name, the types and number of parameters it receives and its return type.
7. Call by value is a method in which the values of actual parameters are passed to the formal parameters. Any change
made in the formal parameters does not reflect in the actual parameters.
8. Parameter refers to any declaration within the parenthesis while defining the function body, whereas argument
refers to expressions or values supplied in the function call.
LAB ACTIVITY
1 Write a Function:
i)Area of Square(side*side)
void area_of_square(int side1, int side2)
{
int area = side1 * side2;
printf(" Area of Square = %d\n", area);
}

ii) Area of Rectangle(length*breadth}


void area_of_rect(int I, int b)
{
int area= I *b;
printf(" Area of rectangle =%d\n", area);
}

2.
#include<stdio.h>
#include<conio.h>
void prime(int a);
void main()
{
int n;
clrscr();
printf("\nEnter any number", n);
scanf("%d",&n);
prime(n);
}
void prime(int a)
{
int f= O;
int i ;
for (i = 1; i <= a; i++) {
if (a % i == O)
{
f++;
}
}
if (f == 2)
{
printf("n is a Prime number");
}
else
{
printf("n is not a Prime number");
}
getch();
}

3.
#include<stdio.h>
#include<conio.h>
function1();
function2();
void main()
{
clrscr();
printf("First function \n");
function1();
printf("Second function \n");
function2();
getch();
}
function1()
{
printf("Welcome and good luck for class 10 \n");
}
function2()
{
printf("Perseverance leads to success");
}

4.
#include<stdio.h>
#include<conio.h>
find_cube(int n); //function prototype
void main()
{
clrscr();
int n;
printf("Enter number \n" );
scanf("%d",&n);
find_cube(n); //function calling
getch();
}
find_cube(int n) //function definition
{
int cube=n*n*n;
printf("Cube of the number is= %d \n",cube);
}

5.
#include<stdio.h>
#include<conio.h>
void series( int a);
void main()
{

int n;
printf("\nEnter the value" );
scanf("%d", &n);
series(n);
}
void series( int a)
{
int sum = 0, i;
for(i=l; i<=a; ++i)
sum+=i;
printf("Sum= %d", sum);
getch();
}

6.
#include <stdio.h>
#include<conio.h>
void hcf(int a, int b);
void lcm(int a, int b);

void main()
{
int c, d;

printf("Enter the two numbers to find their HCF: ");


scanf("%d%d", &c, &d);
hcf(c, d);
lcm(c,d);
getch();
void hcf(int a, int b)
{
while (a != b)
{
if (a > b)
{
a = a - b;
}
else
{
b = b - a;

}
printf("The HCF is %d", a);
}
void lcm(int a, int b)
{
int i =1;
for(; a != b; i++)
{
if((a*i)%b == O)
break;
}
printf("\nLCM is %d", a*i);
}
7.
#include<stdio.h>
#include<conio.h>
swap(int x,int y);
void main()
{
int x,y;
printf("Enter first number \n" );
scanf("%d",&x);
printf("Enter second number \n" );
scanf("%d",&y);
swap(x,y);
getch();
}
swap(int x, int y)
{
x=x+y;
y=x-y;
x=x-y;
printf("After swapping : x = %d, y = %d", x, y);
}

CH- 9 INTRODUCTION TO C++


A. Fill in the blanks:
1. Object
2. Class
3. Encapsulation
4. Data Abstraction
5. Child class
6. Attributes, Behaviour
7. Methods
B. State True or False:
1. False
2. True
3. True
4. True
5. False
6. False
7. True
8. False
C. Mutliple Choice Questions:
1. (a) Characteristics
2. (a) Class
3. (a) Method overriding
4. (b) Inheritance
5. (b) Super class
6. (c ) Polymorphism
7. (c) Data abstraction
D. Answer in one word:
1. ....... .
2. Bjarne Stroustrup
3. II
4. Object Oriented Programming
5. Program execution begins with main() function.
6. void keyword indicates that the program will not return any value.
7. cout statement is used to print any message on the screen.
8. #include<iostream.h>
E. Answer the following:
1. C++ is a very popular Object Oriented Programming language. It is an extension of C language. Its applications are:
a) It is a versatile language for handling very large programs.
b) C++ programs can be managed and expanded.
C) It gives the ability to get closer to the machine level details.
d) It is primarily used for developing system/application software, drivers, client-server applications, etc.
2. An object is a real world entity that has two things: Attributes and Behaviour. For example, car is an object. It trans­
ports people to different locations by controlling its speed and direction. It has a switch to turn it on, a steering to
control its direction, an accelerator to increase or decrease its speed. These functions control the car's data that is the
direction, the position and the speed.
3. Once a class is made, users can create any number of objects of that class. It creates objects that have the same
properties and common behaviours. Therefore, a class is called a factory of objects.
4. Inheritance is a process by which a class acquires the properties of another class. In programming, it allows the re­
usability of the code. Once a code has been defined in the parent class, it can be used by child class.
5. Data abstraction means data hiding. It is the concept of hiding unnecessary details and representing only the very
essential features. For example, the details of structures and circuits of a cell phone is hidden and only essential com­
ponents, like numbers, call, end, clear, message buttons are available to us.
6. The process of combining data and functions into a single unit is called encapsulation. Objects with similar attributes
and behaviour are grouped into a class. For example, a cell phone has its features, like size, shape, different ring tones,
memory space, messages, etc. It has its own behavior, like send and receive calls and messages, games, etc. Thus, its
attributes and behaviour are bound in one unit that is cell phone.
7.
C C++
1. C is a procedural programming language. 1. It is a procedural and object oriented language.
2. It cannot run C++ codes. 2. It can run most of the C codes.
3. Reusability of existing code is difficult in C. 3. It is easy to reuse the existing code in C++.
4. It does not support abstraction, encapsulation, 4. It supports abstraction, encapsulation, polymer-
polymorphism, and inheritance. phism, and inheritance.
8. Method overriding is a process of creating a new method in a child class to change the behaviour inherited from the
parent class.
LAB ACTIVITY
1.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"Welcome to the world of C++ programming";
getch();
}
2. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout«" Kunal Kunal Kunal Kunal "«endl;
getch();
}

3. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout«"Be Good and Do Good"«endl;
cout<<endl;
cout<<"Be Good and Do Good"<<endl;
cout«endl;
cout«"Be Good and Do Good"«endl;
cout<<endl;
cout<<"Be Good and Do Good"<<endl;
cout«endl;
cout<<"Be Good and Do Good"«endl;
cout«endl;
getch();
}

4. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout«"To acquire knowledge, one must study; but to acquire wisdom, one must observe"«endl;
getch();
}
CH-10 PROGRAMMING INC++
A. Fill in the blanks:
1. Single quotes
2. Whole numbers
3. Float
4. Variable
5. int
6. Relational
7. Data type
8. Loops
9. Branching
10. Expression
B. Write True or False:
1. False
2. False
3. True
4. True
5. False
6. True
7. True
8. True
9. False
10. True

C. Multiple Choice Questions:


1. (b) Explicit
2. (a) Logical operator
3. (c ) Arithmetic operator
4. (d) Tokens
5. (b) Operators
6. (a) Reserved words
D. Answer in one word:
1. Assignment operator
2.48
3. Loop
4. Conditional operator
5. Type conversion
6. Relational operator
E. Answer the following:
1. Tokens define the structure of the C++ language. The smallest meaningful element of C++ program is called a token.
Keywords, identifiers, variables, constants, operators, and punctuators are the tokens in C++.
2. Constants are the values that do not change during the execution of a program. These values may be digits or char­
acters. For example, 5,-22, 'H', "Area", etc. On the other hand, variables are the names given to the memory locations
that store data. Their values can change during the execution of a program. Every variable must be declared before we
use it in the program.
3. In C++, data types are categorized as:
a) Built-in data types (int , char, float , double )
b) User defined data types (Structure, Class, etc.)
c) Derived data types (Array, Function, Pointer, etc.)
4. Data type conversion is a process of changing one data type into another. It prevents the loss of data while dealing
with multiple data types. It helps to convert all data into a single data type and subsequently evaluates the expression.
5. Operators are the special symbols that perform simple and complex calculations. C++ provides the following oper­
ators:
a) Arithmetic b) Relational c) Assignment d) Logical
e) Increment/Decrement f) Conditional
6. Control structures are used to change the flow of execution of a program. The flow control determines how a com­
puter will respond when given certain conditions and parameters. This can be achieved through Branching and Looping
statements. Branches can execute one part of a program instead of another, whereas loops repeat certain parts of a
program.
7. Loops are used to repeat certain parts of a program. They contain a condition and a set of statements. Till the time
condition remains true, the compiler keeps executing the statements. The following program explains the use of for
loop:
Pick program 7 from page 103
F. Write C++ programs for the following:
1. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=5, b=8;
int c= a*b;
cout<<"Product of two numbers is = "<<c;
getch();
}

2. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int r=3;
float area=3.142*r*r;
cout<<"Area of circle is"<<area;
getch();
}
3. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int p=20000, t=3;
float r=2.5;
float si=p*r*t/100;
cout<<"Simple interest is"<<si;
getch();
}
4. #include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
cout<<"Enter any number"<<endl;
int n;
cin>>n;
float sqroot=sqrt(n);
cout<<" Square root of the entered number is"<<sqroot;
getch();
}
5. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n;
cout<<" Enter any number"<<endl;
cin>>n;
cout<<"Factors are:"<<endl;
for(int i=l; i<=n; ++i)
{
if(n%i==0)
cout<<i<<endl;
}
getch();
}
6.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,x,sum=0;
cout<<"How many numbers?";
cin>>n;
for(i=l;i<=n;++i)
{
cout<<"\nEnter number";
cin>>x;
sum+=x;
}
x=sum/n;
cout<<"Average="<<x;
getch();
}

7. #include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
for(i=2;i<=100;i=i+2)
cout<<i<<endl;
getch();
}
8.
#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i,n,sum=0;
cout«" \nEnter the value\n";
cin>>n;
for(i=l;i<=n;++i)
sum+=i;
cout<<"\n Sum="<<sum;
getch();
}

SAMPLE PAPER - II
A. Fill in the blanks:
1. Statements
2. Entry
3. Switch
4. Looping
5. Formal parameters, Actual arguments
6. Empty
7. Encapsulation
8. Attributes, Behaviour
9. Data type
10. Data Abstraction
B. State True or False:
1. False
2. True
3. True
4. False
5. False
6. False
7. True
8. True
9. False
10. True
C. Multiple Choice Questions:
1. (c) do-while
2. (c) is compulsory to be used in a switch statement
3. (b) User defined
4. (c ) Polymorphism
5. (b) Explicit
D. Answer in one word:
1. Compound statements
2. Relational operator
3. Only one of the return statements will get execute.
4. Relational operator
5. <iostream.h>
6. C++ supports 48 keywords
7. Relational operator determines the relation between two operators.
8. Bjarne Stroustrup
9. II
10. Encapsulation

E. Answer the following:


1. The Switch case control structure is used when there is a requirement to check multiple conditions in a program. It
allows a variable to be tested for equality against a list of cases. When one value matches the value of the variable, the
computer continues executing the program from that point. If none of the cases matches, the compiler executes the
default statement.
2. Break statement is used to terminate the execution of the current loop and the control comes out of the loop,
whereas the continue statement skips the next statement and takes the control to the header of the loop.
3. Control structures are used to change the flow of execution of a program. The flow control determines how a com­
puter will respond when given certain conditions and parameters. This can be achieved through Branching and Looping
statements. Branches can execute one part of a program instead of another, whereas loops repeat certain parts of a
program.
4. Parameter refers to any declaration within the parenthesis while defining the function body, whereas argument
refers to expressions or values supplied in the function call.
5. Function prototype is the first line of function definition. It gives information to the compiler about the function
name, the types and number of parameters it receives and its return type.
6. An object is a real world entity that has two things: attributes and behaviour. For example, car is an object. It trans­
ports people to different locations by controlling its speed and direction. It has a switch to turn it on, a steering to
control its direction, an accelerator to increase or decrease its speed. These functions control the car's data that is the
direction, the position and the speed.
7. Method overriding is a process of creating a new method in a child class to change the behaviour inherited from the
parent class.
8. Data type conversion is a process of changing one data type into another. It prevents the loss of data while dealing
with multiple data types. It helps to convert all data into a single data type and subsequently evaluates the expression.
9. Functions are of two types:
a) Library or built-in functions: These functions are grouped together and stored in C library. They perform the basic
110 and mathematical operations.
b) User defined functions: These functions are designed by the user to carry out some specific tasks as per the need in
the program.
10.
C C++
1. C is a procedural programming language. 1. It is a procedural and object oriented language.
2. It cannot run C++ codes. 2. It can run most of the C codes.
3. Reusability of existing code is difficult in C. 3. It is easy to reuse the existing code in C++.
4. It does not support abstraction, encapsulation, 4. It supports abstraction, encapsulation, polymer-
polymorphism, and inheritance. phism, and inheritance.
F. Write short notes on the following:
1. Functions: A function is a block of code that can be reused anywhere in the program. It divides the program in small­
er modules, thus making it easier to read and debug.
2. Object Oriented Programming: It is an art of segregating an application into some number of ob­
jects. Each object exists and works independently of each other. Its main goal is to break the prob­
lem down into a number of smaller problems that are simpler and easier to understand.

You might also like