11th Computer Science 1,2,3, & 5 Marks Question Bank EM
11th Computer Science 1,2,3, & 5 Marks Question Bank EM
11
11 COMPUTER SCIENCE
11th Standard
Computer Science
157 x 1 = 157
1) First generation computers used
(a) Vacuum tubes (b) Transistors (c) Integrated circuits (d) Microprocessors
2) Name the volatile memory
(a) ROM (b) PROM (c) RAM (d) EPROM
3) Identify the output device
(a) Keyboard (b) Memory (c) Monitor (d) Mouse
WHATSAPP - 8056206308
4) Identify the input device
(a) Printer (b) Mouse (c) Plotter (d) Projector
5) _____ output device is used for printing building plan.
(a) Thermal printer (b) Plotter (c) Dot matrix (d) Inkjet printer
6) Which one of the following is used to in ATM machines
(a) Touch Screen (b) Speaker (c) Monitor (d) Printer
n
7) When a system restarts which type of booting is used.
l.i
(a) Warm booting (b) Cold booting (c) Touch boot (d) Real boot
da
8) Expand POST
(a) Post on self Test (b) Power on Software Test (c) Power on Self Test
ka
(a) ROM (b) RAM (c) Flash drive (d) Hard disk
.k
WHATSAPP - 8056206308
(a) Fundamental Gate (b) Derived Gate (c) Logical Gate (d) Universal gate
24) Which of the following is said to be the brain of a computer?
(a) Input devices (b) Output devices (c) Memory device (d) Microprocessor
25) Which of the following is not the part of a microprocessor unit?
(a) ALU (b) Control unit (c) Cache memory (d) register
26) How many bits constitute a word?
n
(a) 8 (b) 16 (c) 32 (d) determined by the processor used.
l.i
27) Which of the following device identifies the location when address is placed in the
da
memory address register?
(a) locator (b) encoder (c) decoder (d) multiplexed
ka
(a) Hard disk (b) Main memory (c) Cache memory (d) Blue-Ray disc
30) How many memory locations are identified by a processor with 8 bits address bus at a
w
time?
w
31) What is the capacity of 12cm diameter DVD with single sided and single layer?
(a) 4.7 GB (b) 5.5 GB (c) 7.8 GB (d) 2.2 GB
32) What is the smallest size of data represented in a CD?
(a) blocks (b) sectors (c) pits (d) tracks
33) Display devices are connected to the computer through
(a) USB port (b) Ps/2 port (c) SCSI port (d) VGA connector
34) Operating system is a
(a) Application Software (b) Hardware (c) System Software (d) Component
35) Identify the usage of Operating Systems
(a) Easy interaction between the human and computer
(b) Controlling Input & Output Devices (c) Managing use of main memory
(d) All the above
36) Which of the following is not a Function of Operating System?
(a) Process Management (b) Memory Management (c) Security management
(d) Compiler Environment
WHATSAPP - 8056206308
42) The File management system used by Linux is
(a) ext2 (b) NTFS (c) FAT (d) NFTS
43) From the options given below, choose the operations managed by the operating
system.
(a) Memory (b) Processes (c) Disks and I/O devices (d) all of the above
44) Which is the default folder for many Windows Applications to save your file?
n
(a) My Document (b) My Pictures (c) Documents and Settings (d) My Computer
l.i
45) Under which of the following OS, the option Shift + Delete - permanently deletes a file
da
or folder?
(a) Windows 7 (b) MS-DOS (c) Linux (d) Android OS
ka
(a) Assemble a bicycle. (b) Describe a bicycle. (c) Label the parts of a bicycle.
(d) Explain how a bicycle works.
49) Which of the following activities is not algorithmic in nature?
(a) Multiply two numbers (b) Draw a kolam (c) Walk in the park
(d) Swaping of two numbers
50) Omitting details inessential to the task and representing only the essential features of
the task is known as
(a) specification (b) abstraction (c) composition (d) decomposition
51) Stating the input property and the input-output relation a problem is known
(a) specification (b) statement (c) algorithm (d) definition
52) Ensuring the input-output relation is
(a) the responsibility of the algorithm and the right of the user.
(b) the responsibility of the user and the right of the algorithm.
(c) the responsibility of the algorithm but not the right of the user.
(d) the responsibility of both the user and the algorithm.
53) If i = 5 before the assignment i := i-1 after the assignment, the value of i is
(a) 5 (b) 4 (c) 3 (d) 2
ANSWERS PDF COST RS.500 ONLY
MY YOUTUBE CHANNEL NAME - RAVI MATHS TUITION CENTER , WHATSAPP - 8056206308
54) If 0 < i before the assignment i := i-1 after the assignment, we can conclude that
(a) 0 < i (b) 0 ≤ i (c) i = 0 (d) 0 ≥ i
55) Suppose u, v = 10, 5 before the assignment. What are the values of u and v after the
sequence of assignments?
1 u :=v
2 v := u
(a) u, v = 5,5 (b) u, v = 5,10 (c) u, v = 10,5 (d) u, v = 10,10
56) Which of the following properties is true after the assignment (at line 3)?
1 --i, j = 0, 0
2 i, j := i+1, j-1
3 -- ?
(a) i + j > 0 (b) i+j < 0 (c) i+j=0 (d) i = j
WHATSAPP - 8056206308
57) If C1 is false and C2 is true, the compound statement
1 if CI
2 SI
3 else
4 if C2
5 S2
6 else
7 S3
n
executes
l.i
(a) S1 (b) S2 (c) S3 (d) none da
58) If C is false just before the loop, the control flows through
1 SI
ka
2 while C
3 S2
vi
4 S3
al
(a) (1) only (b) (2) only (c) both (1) and (2) (d) neither (1) nor (2)
60) How many times the loop is iterated?
i:= 0
while i ≠ 5
i := i+ 1
(a) 4 (b) 5 (c) 6 (d) 0
61) A loop invariant need not be true
(a) at the start of the loop (b) at the start of each iteration
(c) at the end of each iteration (d) at the start of the algorithm
62) We wish to cover a chessboard with dominoes,ロロ the number of black squares and
the number of white squares covered by dominoes, respectively, placing a domino can be
modeled by
(a) b:= b + 2 (b) w:= w + 2 (c) b, w := b + 1, w + 1 (d) b:= w
63) If m x a + n x b is an invariant for the assignment a, b: = a + 8, b + 7, the values of m
and n are
(a) m = 8, n = 7 (b) m = 7, n = -8 (c) m = 7, n = 8 (d) m = 8, n = -7
ANSWERS PDF COST RS.500 ONLY
MY YOUTUBE CHANNEL NAME - RAVI MATHS TUITION CENTER , WHATSAPP - 8056206308
64) Which of the following is not an invariant of the assignment? m, n := m+2, n+3
(a) m mod 2 (b) n mod 3 (c) 3 x m - 2 x n (d) 2 x m - 3 x n
65) If Fibonacci number is defined recursively as
⎧ 0 n = 0
F (n) = ⎨ 1 n = 1
⎩
F(n − 1) + F(n − 2) otherwise
WHATSAPP - 8056206308
(a) 11 (b) 10 (c) 9 (d) 8
67) Who developed C++?
(a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai
68) What was the original name given to C++?
(a) CPP (b) Advanced C (c) C with Classes (d) Class with C
69) Who coined C++?
n
(a) Rick Mascitti (b) Rick Bjarne (c) Bill Gates (d) Dennis Ritchie
70) The smallest individual unit in a program is:
l.i
da
(a) Program (b) Algorithm (c) Flowchart (d) Tokens
71) Which of the following operator is extraction operator of C++?
ka
(a) > > (b) < < (c) < > (d) ^^
vi
(a) Keywords are the reserved words convey specific meaning to the C++ compiler
.k
WHATSAPP - 8056206308
(a) sizeof () (b) int () (c) long () (d) double ()
85) Which operator is used to access reference of a variable?
(a) $ (b) # (c) & (d) !
86) This can be used as alternate to endl command:
(a) \t (b) \b (c) \0 (d) \n
87) What is the alternate name of null statement?
n
(a) No statement (b) Empty statement (c) Void statement (d) Zero statement
l.i
88) In C++, the group of statements should be enclosed within:
da
(a) { } (b) [ ] (c) ( ) (d) < >
ka
89) The set of statements that are executed again and again in iteration is called as:
(a) condition (b) loop (c) statement (d) body of loop
vi
92) How many times the following loop with execute? for (int i=0; i< 10; i++).
w
WHATSAPP - 8056206308
105) cin > > n[3]; To which element does this statement accepts the value?
(a) 2 (b) 3 (c) 4 (d) 5
106) By default, a string ends with which character?
(a) \o (b) \t (c) \n (d) \b
107) Structure definition is terminated by
(a) } (b) ; (c) :: (d) (:)
n
108) What will happen when the structure is declared?
l.i
(a) it will not allocate any memory (b) it will allocate the memory
da
(c) it will be declared and initialized (d) it will be only declared
109) A structure declaration is given below:
ka
struct Time
{
vi
int hours;
al
int minutes;
int seconds;
.k
} t;
w
(a) struct {int num;} (b) struct sum {int num;} (c) struct sum int sum;
(d) struct sum {int num;} ;.
111) A structure declaration is given below
struct employee
{
int empno;
char ename[10];
}e[5] ;
Using above declaration which of the following statement is correct.
(a) cout< < e[0].empno< < e[0].ename; (b) cout< < e[0].empno< < ename;
(c) cout< < e[0]- > empno< < e[0]- > ename; (d) cout< < e.empno< < e.ename;
112) When accessing a structure member, the identifier to the left of the dot operator is
the name of
(a) structure variable (b) structure tag (c) structure member (d) structure function
113) The term is used to describe a programming approach based on classes and objects
is
(a) OOP (b) POP (c) ADT (d) SOP
WHATSAPP - 8056206308
(a) Data hiding (b) Encapsulation (c) Polymorphism (d) Abstraction
119) Which of the following concept encapsulate all the essential properties of the object
that are to be created?
(a) class (b) Encapsulation (c) Polymorphism (d) Abstraction
120) Which of the following is the most important advantage of inheritance?
(a) data hiding (b) code reusability (c) code modification (d) accessibility
121) "Write once and use it multiple time" can be achieved by
n
l.i
(a) redundancy (b) reusability (c) modification (d) composition
da
122) Which of the following supports the transitive nature of data?
(a) Inheritance (b) Encapsulation (c) Polymorphism (d) Abstraction
ka
124) Which of the following statements about member functions are True or False?
al
(i) A member function can call another member function directly with using the dot
.k
operator.
(ii) Member function can access the private data of the class.
w
(a) i-True, ii-True (b) i-False, ii-True (c) i-Trrue, ii-False (d) i-False, ii-False
w
125) A member function can call another member function directly, without using the dot
w
operator called as
(a) sub function (b) sub member (c) nesting of member function
(d) sibling of member function
126) The member function defined within the class behave like________functions.
(a) inline (b) Non inline (c) Outline (d) Data
127) Which of the following access specifier protects data from inadvertent modifications?
(a) Private (b) Protected (c) Public (d) Global
128) class x
{
int y;
public:
x(int z){y=z;}
} x1[4];
int main()
{ x x2(10);
return 0;}
How many objects are created for the above program?
(a) 10 (b) 14 (c) 5 (d) 2
WHATSAPP - 8056206308
(a) Operator overloading (b) Operations overloading (c) Function Overloading
(d) Member overloading
133) void dispchar(char ch='$';int size=10)
{
for(int i=1;i < = size;i++)
cout < < ch
}
n
How will you invoke the function dispchar() for the following input?
l.i
To print $ for 10 times
da
(a) dispchar (); (b) dispchar( ch,size); (c) dispchar($,10); (d) dispchar('$',10 times);
134) Which of the following is not true with respect to function overloading?
ka
(c) The default arguments of overladed functions are not considered for Overloading
(d) Destructor function cannot be overloaded
.k
(a) void fun (intx); (b) void fun (intx); (c) void fun (double d); (d) void fun (double d);
w
void fun (char ch); void fun (inty); void fun (char ch); void fun (inty);
w
136) Which of the following is the process of creating new classes from an existing class
(a) Polymorphism (b) Inheritance (c) Encapsulation (d) super class
137) Which of the following derives a class student from the base class school
(a) school: student (b) class student: public school (c) student: public school
(d) class school: public student
138) The type of inheritance that reflects the transitive nature is
(a) Single Inheritance (b) Multiple Inheritance (c) Multilevel Inheritance
(d) Hybrid Inheritance
139) Which visibility mode should be used when you want the features of the base class
to be available to the derived Class but not to the classes that are derived from the
derived class?
(a) Private (b) Public (c) Protected (d) All of these
140) Inheritance is a process of creating new class from
(a) Base class (b) abstract (c) derived class (d) Function
WHATSAPP - 8056206308
(d) Protected members of base class are inherited but not visible to the outside class.
144) class vehicle
{ int wheels;
public:
void input_data(float,float);
void output_data();
protected:
int passenger;
n
};
l.i
class heavy_vehicle : protected vehicle {
int diesel_petrol;
da
protected:
int load;
ka
public:
void read_data(float,float)
vi
void write_data(); };
al
public:
w
void fetch_data(char);
void display_data(); };
w
(a) Bus (b) heavy_vehicle (c) Vehicle (d) Both (a) and (c)
WHATSAPP - 8056206308
void write_data(); };
class bus: private heavy_vehicle {
char Ticket[20];
public:
void fetch_data(char);
void display_data(); };
The data member that can be accessed from the function display data()
(a) passenger (b) load (c) Ticket (d) All of these
n
146) class vehicle
{ int wheels;
l.i
da
public:
void input_data(float,float);
ka
void output_data();
protected:
vi
int passenger;
};
al
int diesel_petrol;
protected:
w
int load;
w
public:
void read_data(float,float)
w
void write_data(); };
class bus: private heavy_vehicle {
char Ticket[20];
public:
void fetch_data(char);
void display_data(); };
The member function that can be accessed by an objects of bus Class is
(a) input data(), output _data() (b) read _data() ,write _data()
(c) fetch _data(), display_data() (d) All of these
WHATSAPP - 8056206308
void write_data(); };
class bus: private heavy_vehicle {
char Ticket[20];
public:
void fetch_data(char);
void display_data(); };
The member function that is inherited as public by Class Bus
(a) input_data(), output_data() (b) read_data(), write_data()
n
(c) fetch _data(),display _data() (d) none of these
l.i
148) Which of the following deals with procedures, practices and values?
da
(a) piracy (b) programs (c) virus (d) computer ethics
ka
149) Commercial programs made available to the public illegally are known as
(a) freeware (b) warez (c) free software (d) software
vi
150) Which one of the following are self-repeating and do not require a computer program
al
to attach themselves?
.k
WHATSAPP - 8056206308
171) What Is Boolean Algebra?
172) Write a short note on NAND Gate
173) Draw the truth table for XOR gate
174) Write the associative laws?
175) What are derived gates?
176) Convert the following Octal numbers into Binary numbers. - 6458
177) Convert the following Hexadecimal numbers to Binary numbers A6.
n
178) Write the 1's complement number and 2's complement number for the
following decimal number: 22
l.i
da
179) Convert the following Hexadecimal numbers to Binary numbers : BE
180) Convert the following Hexadecimal numbers to Binary numbers BC9.
ka
181) Write the 1's complement number and 2's complement number for the
vi
WHATSAPP - 8056206308
216) What are called standard icons?
217) How will you Rename a File?
218) Define an algorithm.
219) Distinguish between an algorithm and a process
220) Specify a function to find the minimum of two numbers.
221) Distinguish between a condition and a statement.
222) Draw a flowchart for conditional statement.
n
223) Both conditional statement and iterative statement have a condition and a
statement. How do they differ?
l.i
da
224) What is the difference between an algorithm and a program?
225) Why is function an abstraction?
ka
230) What is the relationship between loop invariant, loop condition and the input-output
w
recursively?
w
WHATSAPP - 8056206308
246) Suppose x and y are two double type variable that you want add as integer and
assign to an integer variable. Construct a C++ statement for the doing so.
247) What will be the result of following if num=6 initially.
(a) cout < < num;
(b) cout < < (num == 5);
248) Which of the following two statements are valid? Why? Also write their result.
int a;
n
(i) a = 3,014;
(ii) a=(3,014);
l.i
249) What is meant by literals? How many types of integer literals are available in C++?
da
250) What kind of constants are following? i) 26 ii) 015 iii) 0xF iv) 014.9
251) What is character constant in C++?
ka
WHATSAPP - 8056206308
for (int i = 2; i < = 10 ; i + = 2)
cout < < i;
281) Write a for loop that displays the number from 21 to 30.
282) Write a while loop that displays numbers 2, 4, 6, 8.......20.
283) Compare an if and a?: operator.
284) Define Functions.
285) Write about strlen() function.
n
286) What are importance of void data type.
l.i
287) What is Parameter and list its types?
da
288) Write a note on Local Scope.
289) What is Traversal in an Array?
ka
WHATSAPP - 8056206308
323) Write a short note on Tamil Virtual Academy.
126 x 3 = 378
324) What are the characteristics of a computer?
325) Write the applications of computer
326) What is an input device? Give two examples.
327) Name any three output devices.
328) Differentiate optical and Laser mouse.
n
329) Write short note on impact printer.
330) Write the characteristics of sixth generation.
l.i
da
331) Write the significant features of monitor.
332) Write note on binary number System
ka
333) Convert (150)10 into Binary, then convert that Binary number to Octal.
vi
338) Reason out why the NAND an NOR are called universal gates?
w
WHATSAPP - 8056206308
1) 1920
2) 255
3) 126
351) Convert the given Binary number into its equivalent Decimal, Octal and Hexadecimal
number.
1) 101110101
2) 1011010
3) 101011111
n
352) Differentiate Computer Organization from Computer Architecture.
l.i
353) Classify the microprocessor based on the size of the data .
da
354) Write down the classifications of microprocessors based on the instruction set.
355) Differentiate PROM and EPROM
ka
WHATSAPP - 8056206308
works with digestive system. A physiotherapist abstracts the human body by its
muscular system.
383) Chocolate Bars: A rectangular chocolate bar is divided into squares by horizontal
and vertical grooves. We wish to break the bar into individual squares.
To start with, we have the whole of the bar as a single piece. A cut is made by choosing a
piece and breaking it along one of its grooves. Thus a cut divides a piece into two pieces.
How many cuts are needed to break the bar into its individual squares?
384) Consider Example 6.2, Goat, grass and wolf problem. In this example, we will write a
n
specification of the problem. We will solve it in Example 7.1. The problem involves four
l.i
individuals, and each is at one of the two sides of the river. This means that we can
represent the state by four variables, and each of them has one of the two values. Let us
da
name the variables as farmer, goat, grass and wolf, and their possible values L and R. A
value of L means "at the left side". A value of R means "at the right side". Since the boat
ka
is always with the farmer, it is not important to introduce a variable to represent its
position.
vi
385) In Example 6.11, we abstracted the state of the process by two variables p and c.
al
The next step is to model the process of cutting the chocolate bar. When we make a
.k
single cut of a piece, the number of pieces (p) and the number of cuts (c) both increase
by 1. We can model it by an assignment statement.
w
1 S1
2 -- C is false
w
3 if C
4 S2
5 else
6 S3
7 S4
387) What is case analysis?
388) Draw a flowchart for -3 case analysis using alternative statements.
389) Define a function to double a number in two different ways:
(1) n + n,
(2) 2 x n.
390) For the given two flowcharts write the pseudo code.
391) There are 7 tumblers on a table, all standing upside down. You are allowed to turn
any 2 tumblers simultaneously in one move. Is it possible to reach a situation when all
the tumblers are right side up? (Hint: The parity of the number of upside-down tumblers
is invariant.)
WHATSAPP - 8056206308
before and after the assignment.
-- before: u, v = 20, 15
u, v :=u+5,v-5
-- after: u, v = 25, 10
After assignment (u, v) = (25, 10). But what do you observe about the value of the
function u + v?
397) If we execute the following assignment with (p, c = 10, 9), after the assignment, (p, c)
= (11, 10).
n
-- before : p, c = 10 , 9
l.i
p, c := p + 1, c+1
-- after: p, c = 11 , 10
da
Can you discover an invariant? What is the value of p - c before and after?
398) Design an iterative algorithm to compute an, Let us name the algorithm power(a, n).
ka
For example,
power(10, 4) = 10000
vi
power (2, 5) = 32
Algorithm power (a, n) computes an by multiplying a cumulatively n times.
.k
w
399) Recall the Chocolate bar problem of Example 6.11. How many cuts are needed to
w
WHATSAPP - 8056206308
{
total += v;
cout < < total;
while v < = 10
412) Write a C++ program to print multiplication table of a given number.
413) Write the syntax and purpose of switch statement.
414) Write a short program to print following series:
n
(a) 1 4 7 10...... 40
l.i
415) What is Built-in functions?
da
416) What is the difference between isupper() and toupper() functions?
417) Write about strcmp() function.
ka
423) The following code sums up the total of all students name starting with ‘S’ and
display it.Fill in the blanks with required statements.
w
int main()
{
student s[20];
for(int i = 0; i < 20; i ++)
{
…………………….. //accept student details
}
for(int i = 0; i < 20; i ++)
{
…………………….. //check for name starts with letter “S”
……………………. // display the detail of the checked name
}
return 0;
}
424) How to access members of a structure? Give example.
425) What is called anonymous structure. Give an example
426) What is paradigm? Mention the different types of paradigm.
427) Write a note on the features of procedural programming.
428) List some of the features of modular programming.
429) What do you mean by modularization and software reuse?
ANSWERS PDF COST RS.500 ONLY
MY YOUTUBE CHANNEL NAME - RAVI MATHS TUITION CENTER , WHATSAPP - 8056206308
430) Define information hiding.
431) Rewrite the following program after removing the syntax errors if any and underline
the errors:
#include
$include
class mystud
{ int studid =1001;
char name[20];
public
mystud( ) { }
void register ( )
{cin > > stdid; gets(name); }
void display ( )
{cout< < studid< < ”: “< < name< < endl;}
WHATSAPP - 8056206308
}
int main( )
{ mystud MS;
register.MS( );
MS.display( );
}
432) Write with example how will you dynamically initialize objects?
433) What are advantages of declaring constructors and destructor under public
n
accessability?
l.i
434) Given the following C++ code, answer the questions (i) & (ii).
da
class TestMeOut
{
ka
public:
~TestMeOut() //Function 1
vi
(i) In Object Oriented Programming, what is Function 1 referred as and when doesit get
w
invoked / called ?
(ii) In Object Oriented Programming, what is Function 2 referred as and when doesit get
w
invoked / called ?
435) What are the rules for function overloading?
436) How does a compiler decide as to which function should be invoked when there are
many functions? Give an example.
437) What is operator overloading? Give some example of operators which can be
overloaded.
438) Discuss the benefits of constructor overloading?
439) class sale ( int cost, discount ;public: sale(sale &); Write a non inline definition for
constructor specified;
440) What are the points to be noted while deriving a new class?
441) What is difference between the members present in the private visibility mode and
the members present in the public visibility mode
442) What is the difference between polymorphism and inheritance though are used for
reusability of code?
443) What do you mean by overriding?
444) Write some facts about the execution of constructors and destructors in inheritance.
445) What is the role of firewalls?
446) Write about encryption and decryption.
ANSWERS PDF COST RS.500 ONLY
MY YOUTUBE CHANNEL NAME - RAVI MATHS TUITION CENTER , WHATSAPP - 8056206308
447) Explain about proxy server.
448) What are the guidelines to be followed by any computer user?
449) What are ethical issues? Name some.
85 x 5 = 425
450) Explain the basic components of a computer with a neat diagram.
451) Discuss the various generations of computers.
452) Explain the following:
a. Inkjet Printer
b. Multimedia projector
c. Bar code / QR code Reader
453) Write the procedure to convert fractional Decimal to Binary.
454) Convert (98.46)10 to Bianary.
455) Find 1's Complement and 2's Complement for the following Decimal number.
WHATSAPP - 8056206308
(i) -98
(ii) -135
456) Add 11010102 + 1011012
457) Subtract 11010112 - 1110102
458) Explain the fundamental gates with expression and truth table.
459) How AND and OR can be realized using NAND and NOR gate
460) Explain the Derived gates with expression and truth table.
n
461) State whether the following numbers are valid or not. If invalid, given reason.
1. 786 is an octal number
l.i
da
2. 101 is a binary number
3. radix of octal number is 7
ka
464) Arrange the memory devices in ascending order based on the access time.
al
466) Explain the concept of a Distributed Operating System along with its advantages.
w
467) List out the points to be noted while creating a user interface for an Operating
system.
w
474) Exchange the contents: Given two glasses marked A and B. Glass A is full of apple
drink and glass B is full of grape drink. For exchanging the contents of glasses A and B,
represent the state by suitable variables, and write the specification of the algorithm.
475) What are the values of variables m and n after the assignments in line (1) and line
(3)?
478) Decanting problem. You are given three bottles of capacities 5, 8 and 3 litres. The 8L
bottle is filled with oil, while the other two are empty. Divide the oil in 8L bottle into two
equal quantities. Represent the state of the process by appropriate variables. What are
the initial and final states of the process? Model the decanting of oil from one bottle to
another by assignment. Write a sequence of assignments to achieve the final state.
WHATSAPP - 8056206308
479) Trace the step-by-step execution of the algorithm for factorial(4).
factorial(n)
--inputs: n is an integer, n > 0
-- outputs: f = n!
f, i := 1 ,1
while i < nf
, i := f × i, i+1
480) Let us solve the Farmer, Goat, Grass, and Wolf problem of Example 6.12. We decided
n
to represent the state of the process by four variables farmer, goat, grass, and wolf,
l.i
representing the sides of the farmer, goat, grass and wolf, respectively. In the initial
da
state, all four variables have the value L (Left side). In the final state, all four variables
should have the value R (Right side). The goal is to construct a statement S so as to
ka
minimum of the two using the alternative statement. Let us store the minimum in a
variable named result.
al
482) We want an algorithm that compares two numbers and produces the result
.k
as compare
w
⎧ 1− if a < b
w
(a, b) = ⎨ 0 if a = b
⎩
1 if a > b
w
We can split the state into an exhaustive set of 3 disjoint cases: a < b, a = b, and a > b.
Then we can define compare() using a case analysis.
483) Construct an iterative algorithm to compute the quotient and remainder after
dividing an integer A by another integer B.
484) In the Chameleons of Chromeland problem of Example 1.3, suppose two types of
chameleons are equal in number. Construct an algorithm that arranges meetings
between these two types so that they change their color to the third type. In the end, all
should display the same color.
485) Consider a school goer's action in the morning. The action can be written as
1 Get ready for school
We can decompose this action into smaller, more manageable action steps which she
takes in sequence:
1 Eat breakfast
2 Put on clothes
3 Leave home
486) Consider the problem of testing whether a triangle is right-angled, given its three
sides a, b, c, where c is the longest side. The triangle is right-angled, if
c 2 = a2 + b2
Construct a recursive algorithm using this definition. How many multiplications are
needed to calculate a10?
488) There are 6 equally spaced trees and 6 sparrows sitting on these trees,one sparrow
on each tree. If a sparrow flies from one tree to another, then at the same time, another
sparrow flies from its tree to some other tree the same distance away, but in the opposite
direction. Is it possible for all the sparrows to gather on one tree?
489) Customers are waiting in a line at a counter. The man at the counter wants to know
how many customers are waiting in the line.
490) Assume an 8 × 8 chessboard with the usual coloring. "Recoloring" operation changes
WHATSAPP - 8056206308
the color of all squares of a row or a column. You can recolor re-peatedly. The goal is to
attain just one black square. Show that you cannot achieve the goal. (Hint: If a row or
column has b black squares, it changes by (|8 - b) - b|).
491) A single-square-covered board is a board of 2n x 2n squares in which one square is
covered with a single square tile. Show that it is possible to cover the this board with
triominoes without overlap.
492) Design a recursive algorithm to compute an, We constructed an iterative algorithm to
compute an in Example 8.5. an can be defined recursively as
n
1 if n = 0
l.i
n
a = {
n n−1
a × a otherwise
da
493) Write about Binary operators used in C++.
494) What are the types of Errors?
ka
496) What is an entry control loop? Explain any one of the entry controlled loop with
suitable example.
al
497) Write a program to find the LCM and GDC of two numbers.
.k
2 3 4 5 6
(a) x − +
x
2!
− +
x
3!
−
x
4!
x
5!
x
6!
w
2 3 n
(b) x +
x
2
+
x
3
+. . . +
x
n
w
WHATSAPP - 8056206308
cout< < "\nDetails of Book No " < < 2 < < "\n";
cout< < "------------------------\n";
cout< < "Book Name :"< < strcpy(a[1].name,"C++programming" )< < endl;
cout< < "Book Author :"< < strcpy(a[1].author,"BjarneStroustrup ")< < endl;
cout< < "\n\n";
cout< < "================================================\n";
cout< < " S.No\t| Book Name\t|author\n";
cout< < "====================================================";
n
for (int i = 0; i < 2; i++) {
l.i
cout< < "\n " < < i + 1 < < "\t|" < < a[i].name < < "\t| " < < a[i].author;
}
da
cout< < "\n=================================================";
return 0;
ka
}
508) Write the output of the following c++ program
vi
struct student
w
{
introll_no;
w
char name[10];
w
long phone_number;
};
int main(){
student p1 = {1,"Brown",123443},p2;
p2.roll_no = 2;
strcpy(p2.name ,"Sam");
p2.phone_number = 1234567822;
cout< < "First Student" < < endl;
cout< < "roll no : " < < p1.roll_no < < endl< < "name : " < < p1.name < < endl;
cout< < "phone no : " < < p1.phone_number < < endl;
cout< < "Second Student" < < endl;
cout< < "roll no : " < < p2.roll_no < < endl< < "name : " < < p2.name < < endl;
cout< < "phone no : " < < p2.phone_number < < endl;
return 0;
}
WHATSAPP - 8056206308
cout< < people.firstName< < ‘ ‘ < < people.lastName < < people.age;
}
for (int i = 0; i < 10; i++)
{
cout< < "Enter first name: "; cin< < peop[i].firstName;
cout< < "Enter last name: "; cin > > peop[i].lastName;
cout< < "Enter age: "; cin > > people[i].age;}
}
n
510) Write the differences between Object Oriented Programming and procedural
l.i
programming
511) What are the advanatges of OOPs?
da
512) Write a note on the basic concepts that suppors OOPs?
ka
Private members:
al
Public member:
GetInfo( ) /* Function to Read the information like name, room no, charges and days */
DispInfo ( ) /* Function to display all entered details and total amount calculated using
COMPUTE function */
WHATSAPP - 8056206308
marks=marks+30;
cout< < "Name: Bharathi"< < endl;
cout< < "Roll no : "< < rno< < "\n";
cout< < "Marks : "< < marks< < endl;
}
};
int main()
{
n
student s(14,70);
l.i
s.printdet();
cout< < "Back to Main";
da
return 0;
}
ka
classBook
al
{
.k
Book( ) //Function 1
w
{
fees=1000;
w
BookCode=1;
strcpy (Bookname,"C++");
}
void display(float C) //Function 2
{ cout< < BookCode< < ":"< < Bookname< < ":"< < fees< < endl; }
~Book( ) //Function 3
{ cout< < "End of Book Object"< < endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};
(i) In the above program, what are Function 1 and Function 4 combined together referred
as?
(ii) Which concept is illustrated by Function3? When is this function called/ invoked?
(iii) What is the use of Function3?
(iv) Write the statements in main to invoke function1 and function2
(v) Write the definition for Function4.
WHATSAPP - 8056206308
{
Time=Duration;cout < < "Welcome to Seminar "< < endl; }
Seminar(Seminar &D)
{
Time=D.Time;cout < < "Recap of Previous Seminar Content "< < endl; }
~Seminar()
{
cout < < "Vote of thanks"< < endl; }
n
};
l.i
int main()
{
da
Seminar s1,s2(2),s3(s2);
s1.Lecture();
ka
return 0;
}
vi
al
.k
w
w
w
WHATSAPP - 8056206308
{
if(strcmp(s,ob.s)==0)
cout < < "\nStrings are Equal";
else
cout < < "\nStrings are not Equal";
}
int main()
{
n
comp ob, ob1;
l.i
char string1[10], string2[10];
cout < < "Enter First String:";
da
cin > > string1;
ob.getstring(string1);
ka
ob1.getstring(string2);
al
ob==ob1;
return 0;
.k
}
w
(i) Mention the objects which will have the scope till the end of the program.
(ii) Name the object which gets destroyed in between the program
w
(iii) Name the operator which is over loaded and write the statement that invokes it.
w
WHATSAPP - 8056206308
float M{5};
protected:
char Grade[5];
public:
Marks();
void M entry();
void M display();
};
n
class Result:public Marks
l.i
{
float Total,Agg;
da
public:
char FinalGrade, Commence[20];
ka
Result();
void R calculate();
vi
void R display();
al
}:
(i) Which type of Inheritance is shown in the program?
.k
w
w
w
WHATSAPP - 8056206308
~A( )
{
cout< < endl< < " Bye ";} };
};
class B : public A
{
protected:
int y;
n
public:
l.i
B(int x, int y)
{ x = x1;
da
y = y1; }
B( )
ka
{
cout< < endl< < " I am class B "< < endl; }
vi
~B( )
al
{
cout< < endl< < " Bye "; }
.k
void show( )
w
{
cout< < "x = "< < x< < endl;
w
};
int main( )
{
A objA;
B objB(30, 20);
objB.show( );
return 0;
}
WHATSAPP - 8056206308
b2=a2;
a3=a3;
cout< < b1< < ’\t’< < b2< < ’t\’< < b3; }
void main()
{ B der;
der1:func(); }
525) Consider the following c++ code and answer the questions
class Personal
n
{
l.i
int Class,Rno;
char Section;
da
protected:
char Name[20];
ka
public:
personal();
vi
void pentry();
al
void Pdisplay(); };
class Marks:private Personal
.k
{ float M{5};
w
protected:
char Grade[5];
w
public:
w
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
public:
char FinalGrade, Commence[20];
Result();
void Rcalculate();
void Rdisplay();
};
(ii) Specify the visibility mode of base classes.
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(iii) Give the sequence of Constructor/Destructor Invocation when object of class author
vi
is created.
al
.k
w
w
w
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(iv) Name the base class(/es) and derived class (/es).
vi
al
.k
w
w
w
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(v) Give number of bytes to be occupied by the object of the following class:
vi
(a) publisher
al
(b) branch
(c) author.
.k
w
w
w
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(vi) Write the names of data members accessible from the object of class Result.
vi
al
.k
w
w
w
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(vii) Write the names of all member functions accessible from the object of class Result
vi
al
.k
w
w
w
WHATSAPP - 8056206308
char Grade[5];
public:
Marks();
void Mentry();
void Mdisplay(); };
class Result:public Marks
{
float Total,Agg;
n
public:
l.i
char FinalGrade, Commence[20];
Result();
da
void Rcalculate();
void Rdisplay();
ka
};
(viii) Write the names of all members accessible from member functionsof class Result
vi
533) What is piracy? Mention the types of piracy? How can it be prevented?
.k
*****************************************
w