 CPP All : Concept Notes and Resources #### Some Commonly asked Function/Objects Vs. header files (CBSE 12th Exam) #7735

Concept Learning Code Sheets #### Simple declaration, value putting and direct value display from 2D array #7527

A simple code to declare a 2D array, direct value putting and value recall.

#### Initialising and Displaying a 2D Array #1887

Displaying a 2 dimensional array which is pre-filled with initialised data in the row column format.

#### Hello World #1235

This is traditional program we always start by simply displaying some characters on standard output device.

#### Hello World (Variation for Older Compilers) #1237

This is a traditional program we always start by simply displaying some characters on standard output device. This variation works on older compilers like “Turbo C”still used in some schools. #### Check if string is a palindrome using a function. #1395

Check if a character array or c-style string is same (Palindrome) when reversed using an independent function.

#### Finding Size of CPP Data Types #1426

program shows use of sizeof operator to display the storage size of different data types #### Checking for Armstrong Number (3 Digit) #1539

Program takes integer input and finds if given number is an armstrong number

#### Armstrong number n digit #1573

Checking for armstrong number which can be even more than 3 digit.

#### Check if number is a palindrome #1575

To check if given number is same even if reversed (Palindrome).

#### Reversing an integer #1579

Printing a positive integer in reverse form. for e.g. printing 123 as 321.

#### Check for perfect number #1582

Check if the sum of all the divisors of a number brings the number itself.

#### All factors (divisors) of a number #1584

Printing all factors or divisors of an integer number.

#### Check for prime number (1 and n exclusion technique) #1587

Check if a number has only two factors 1 and the number itself. The 1 and n exclusion technique does not test division with these two obvious divisors and does it for all other possible divisors.

#### Preparing basic arrays #1593

Here we shall prepare some basic arrays of integers, fractions, characters and strings. #### Largest number in integer array #1610

Traversing an integer array linearly to find the largest number in the array. #### Student Marks 3 Subjects 2D Array #1618

Showing how multiple students marks in multiple subjects can be stored and used in 2D Array. #### Char array variations #1623

Learning character array variations and need for null terminator

#### Linear search in array for search term presence and location #1630

Search for presence of element in an integer array for search term presence and location of element where it is found first.

#### Matrix addition 2D with pre-initialised values #1635

Adding two 2D integer matrix into a third matrix of same size with values pre-initialised at the beginning.

#### Simple user input in integer form #1712

Learning the ways to take simple user input in integer form.

#### Multiple integer inputs without extraction chaining #1715

Taking more than one integer input without chaining of io extraction operator >>

#### Multiple integer entries with extraction operator chaining #1717

Way to enter multiple integer entries in one go using extraction operator chaining

#### Input of different data types using cin #1719

Learning to input different data types using the standard console in object.

#### Trying to input a string using cin #1721

Learning the behaviour of cin on c-style string (null terminated character arrays).

#### Anomaly of successive use of cin for char arrays #1726

Successive use of cin will pose some difficulty when used with char arrays or c-style strings.

#### Operators based on operand count #1728

Binary, unary and ternary operator classification is based on number of operands.

#### Operators for assignment #1734

Here we demonstrate the simple assignment and its variations.

#### Operators for comparison #1736

Using operators for equality, inequality, greater, lesser, greater or equal, lesser or equal types of comparisons.

#### Operators for logical use #1739

Testing the use of logical operators like not, and and or operators.

#### Comma as operator #1741

Comma is a sort of operator which can help form multiple instructions within same instruction.

#### Bitwise operators #1743

Bit-wise operators work after the given operands are converted to their binary equivalent value.

#### Typecasting operator #1745

Typecasting or conversion of data type is some times essentially required. This is also a kind of operator in c++

#### Typecasting while outputting #1747

Type casting is often useful for manipulating display while outputting data.

#### sizeof operator #1750

Datatype size is found by using the sizeof operator in c++

#### Simple case of precedence #1752

The order in which operators are applied on operands in an expression can be understood with this example.

#### Operator precedence with value change within expression #1784

Learning operator precedence case when value changes while evaluating the expression.

#### Building speed formula for different units of measurement #1822

Formula building can be done for different units using different divisors.

#### Formulas with powers and roots #1824

Creating formulas that contain powers and square root.

#### Simple interest and amount formulation #1826

Calculating simple interest and amount by using typical formulas.

#### Finding area and circumference of a circle #1828

Area and circumference of circle with use of constant value of PI

#### Celsius to Fahrenheit Conversion #1843

Temperature conversion from degree Celsius to degree Fahrenheit using standard formula

#### Temperature conversion c2f and f2c #1845

Converting given temperature assuming if it is in Celsius as Fahrenheit and if is in Fahrenheit as Celsius

#### Salary Calculation #1847

A real world application of financial calculation with an example of salary calculations

#### Finding bricks required to build a wall #1849

Bricks required to build a wall with an assumption of walls made with bricks only.

#### Finding the paint quantity for door painting #1851

Based on the spread of the paint, exact paint quantity can be computed for a given door size.

#### Simple If – Senior Citizen Test #1854

Taking age as input and finding if it is greater or equal to 60.

#### Check for non zero input value #1859

Take user input as a positive, negative or zero integer value and check if it is a non zero value.

#### Making a number absolute using If #1861

A number is made absolute by removing its negative sign if present.

#### Weather Check – Multiple Instruction in If Scope #1863

We collect weather temperature from user and do a range check, then if true will do multiple instructions in the if block scope.

#### Checking for Digit using if else #1865

Collecting a char input and checking the input as a digit or a non-digit.

#### Stock Finished Check – If Else #1872

Check if stock is finished using if-else selection condition

#### Check for alphabet – “Not an alphabet” as True Condition #1874

Checking for user’s entry being not an alphabet first, else tell that it is an alphabet

#### Check for alphabet – “Is an alphabet” as True Condition #1876

Checking for user’s entry being is an alphabet first, else tell that it is not an alphabet

#### Applying Discounts – Only 1 Volume Slab #1878

Applying discounts on price based on only 1 quantity or volume of purchase based slab.

#### Comparing age of two friends of different age #1880

With this program we can find who is elder amongst the friends of different age.

#### Sum of all members of 2D array #1889

Finding the sum of all members of a matrix having number values.

#### Sum of each row and all members of 2D array #1891

Finding the sum of each row and all members of a matrix having number values.

#### Sum of each row and row addition of 2D array #1893

Finding the sum of each row and then sum of all members by adding each row addition of a matrix having number values.

#### Print square of a 2D array in row-column format #1895

Printing a 2D matrix with each value squared in a proper rows and column format that looks like a matrix.

#### If Else If – Simple If Ladder #1914

Simple if-else-if in a ladder style comparison

#### If Else If – Age of Friend problem bettered #1917

Simple if-else-if in a ladder style comparison to resolve age of friends problem which was not able to compare two friends with equal age.

#### Volume purchase discount – multiple levels #1922

Calculating volume discounts on purchase quantity volumes based on multiple levels of quantity slabs.

#### Marks Based Division #1924

Finding division of a student based on marks using if-else-if ladder #### Electricity Bill – if-else-if – successive slab-wise rates #1929

Classic case of successive slab wise rates calculation for electricity bill generation solved using if-else-if and slab rate formulas.

#### Check character entry as digit, uppercase, lowercase, special #1931

Finding if the character entered by the user is a digit, upper case alphabet, lower case alphabet or other special character using if-else-if ladder. #### Age and gender discount – Nested if condition #1937

Solving for more than one if conditions using nested if for conditions on age and gender of person

#### Territory-wise volume based sales commission – nested if #1945

Finding the volume based sales commissions based on multiple territories using the nesting of if conditions

#### Multiple if conditions #1947

Using multiple if conditions which are often redundant in nature.

#### Body temperature diagnosis and diversion – Multiple if and if ladder #1950

Handling of patients diversion to doctors based on there body temperatures using multiple if and if ladder.

#### Userid and password verification – nested if #1953

Learning to verrify user id and password using nested if selection

#### Userid-password match with common mismatch message #1956

Matching of userid and password in the same condition and if not matched giving a common mismatch message.

#### Userid, password match with dangling else issue #1959

Userid and password matching with nested if and the dangling else issues.

#### Finding the day by days of week number – switch case #1963

User gives the day number and the program outputs the day name for five days and holiday for sat. and sun.

#### Finding the day by days of week number – if else #1968

User gives the day number and the program outputs the day name for five days and holiday for sat. and sun. using the if else logic instead of switch case

#### Checking if character entered is a vowel – switch-case #1973

Entering a character from console and then checking if entered character is a vowel or something else.

#### Finding quarter of the year based on month – switch case #1975

User inputs the month code from 1 to 12 and the output indicates the quarter of the month which it falls in.

#### Menu creation using switch-case #1978

Creating a menu using switch case and run appropriate code piece based on menu selection.

#### Repeating a message with for loop #1982

Using for loop construct the same code piece can be repeated a fixed number of times.

#### Sum of natural numbers within a range – for loop #1986

We use a for loop to sum numbers from 1 to 10. This can changed to any other range also.

#### Sum of natural numbers within a range – while loop #1989

We use a while loop to sum numbers from values filled in begin and end.

#### Print table of an integer number #1992

Printing the table of an integer number like 5×1=5, 5×2=10, 5×3=15 and so on.

#### For and while loop comparison #1995

Comparing simple for and while loop with a simple number printing example

#### Odd number series with double step counter – for loop #1997

Printing odd number series by incrementing counter in double step using for loop

#### Odd number series with divisibility test – for loop #1999

Printing odd number series by testing divisibility test on each number in the for loop

#### Multiple initialisation and multiple step instructions in for loop #2003

A demonstration program to show how multiple initialisation and multiple step instructions in for loop can be used

#### Print till Z with loop count calculation #2034

As user enters a lower case or upper case alphabet the program prints from that alphabet till z.

#### Print till Z with while loop boundary crossing #2038

As user enters a lower case or upper case alphabet the program prints from that alphabet till z using the faster technique of while loop iteration and checking for outside boundary condition

#### Factorial program with limit checking and digit series printing #2042

A program that finds the factorial of a program and checks the limit of number when incorrect outputs may occur due to data size.

#### Finding odd even number using a switch case #2056

Finding if the given number is odd or even using a switch-case construct.

#### Calculator using the switch case #2059

A program that works like a calculator for two input numbers and works for most arithmetic operations like addition, subtraction, multiplication, division etc.

#### Continuous sum using do-while exit on 0 input #2061

This program sums the user inputs continuously and if user input 0 it terminates the loop and displays the sum.

#### Redo of program activity using a do-while loop #2064

Use of do-while loop to redo or re-perform a program activity using a do-while loop. Here we shall redo the activity of printing a number table.

#### Sum of sales using break in while loop #2071

Program to demonstrate an infinite while loop and the use of break in loop

#### Sum of sales using break in for loop #2073

Program to demonstrate an infinite for loop and the use of break in loop

#### Empty code block in a for loop #2078

Demonstration of empty code block in a for loop for using the loop as a delay loop.

#### Odd number series using continue in the for loop #2085

Program to print the series of odd numbers using an alternative technique of using the continue within the for loop.

#### Odd number series using continue in the while loop #2088

Program to print the series of odd numbers using an alternative technique of using the continue within the while loop.

#### Scope of variables declared inside loop #2092

Reuse  of variable declared in a loop scope for another loop.

#### Extracting digits of a number #2104

Loops can be used for extracting the digits one by one by judicious use of  the % and / operators.

#### Sum of digits of a number #2106

Finding the sum of individual digits in a number

#### Reverse printing a number using a loop #2115

Printing a number in reverse order of digit by using digit extraction technique in a loop

#### Extracting and printing the first and last digit of a number #2119

Using a loop technique and successive division by 10 to extract first and last digit of a given number and then printing it.

#### Math functions – sqrt/ pow/ log/ log10 #2127

See the working of some common math functions like sqrt, pow, log and log10

#### Basic Trigonometric functions #2130

Using trigonometric functions like sin, cos and tan etc. in c++

#### Maths – Rounding and related Functions #2135

Rounding and related functions like ceil, floor, round, rint, trunc etc. in c++

#### Absolute value functions abs() fabs() #2137

Using absolute value functions like fabs() and abs().

#### fmod( ) – Modulus function for fractions #2143

Using the specially created modulus function fmod() for fractions like float and double data type.

#### modf() – Function to separate integer and fraction part #2145

Using the modf() function to separate the integer and fraction part of fractional value.

#### Uppercase/lowercase and vice-versa conversion of alphabets #2147

Using toupper() and tolower() function for character level conversion in its ascii integer form.

#### Check character group as alpha, digit, control, punctuation, lower, upper etc. #2150

Check for character grouping in the ascii 7 bit range of control character, digit, punctuation, alphabet, alphanumeric, lowercase, uppercase, printable, graphical, white space etc.

#### getchar() putchar() : C-Style character level console I/O functions #2155

The functions which are frequently used in C, getchar() and putchar() provide a feature of character level console input and output facility.

#### get() put() functions of stream I/O #2160

Using get() and put functions of I/O stream methods like cin and cout.

#### getline() and write() functions of stream I/O #2175

Use of functions getline() and write of cin and cout steam I/O objects.

#### Function with single parameter to evaluate an expression #2179

Writing a function with one parameter to evaluate an expression.

#### Area, circumference of circle using two functions #2182

Finding and area and circumference of a circle using two separate functions for each of them #### Sum of digits program using a function #2189

Writing function sumofdigits() to add the digits in any integer number and then using this function in the main function. #### Repeated display function without any returned value – void type #2214

Function to repeat a character in display for number of times desired.

#### Setting default parameters in function prototype #2243

The default parameters in function becomes active when given parameter value is not passed. Here we learn this setting at the level of function prototype.

#### Setting default parameters in function definition #2250

The default parameters in function becomes active when given parameter value is not passed. Here we learn this setting at the level of function definition.

#### Using constant argument/parameter in a function #2255

Writing a program to find student division using the const argument for maximum marks.

Writing polymorphic function based on difference on number of parameters.

Writing polymorphic function based on difference on parameters data type.

#### Dangling else Problem in Leap Year Calculation #2284

Understanding dangling else problem in a typical leap year calculation situation.

#### Using some popular escape sequence characters. #2288

Using some escape sequences in c++ for common tasks.

#### Input as char data and outputting as int data. #2310

A character data can be outputted as int data by typecasting.

#### Age based discount using ternary operator #2318

Solving age based discount problem with ternary (three operands) operator.

#### Square terms series #2353

Printing 10 terms of square terms of natural numbers beginning from 1.

#### Series building concept with different term expression builder and term counter #2364

It is possible to build many series expression easily when we take different variables for term counting and term expression building.

#### Series based on x^2+x+1 #2367

Writing 10 terms of a series based on x^2+x+1 where x is taken from user.

#### Function in function calls using salary preparation example #2375

Using the example of salary preparation for building related functions and using function in function calls.

#### Factorial table printing with number and its factorial #2382

Printing a table of numbers followed by its factorial.

#### Fibonacci series from 1 (All terms using loop) #2392

Printing 10 terms of Fibonacci series  starting from 1 like 1 1 2 3 5 8 13 21 34 55 . All terms are printed using the loop.

#### Fibonacci series from 0 (All terms using loop) #2404

Printing 10 terms of Fibonacci series  starting from 0 like 0 1 1 2 3 5 8 13 21 34 . All terms are printed using the loop.

#### Fibonacci series from 0 (Fixed first two terms) #2409

Printing 10 terms of Fibonacci series  starting from 0 like 0 1 1 2 3 5 8 13 21 34 . First two terms are printed as fixed terms and rest all terms are printed using the loop.

#### Prime number series #2429

Print a series of prime numbers up to predefined number of terms..

#### Simple Geometric series 1+x+x^2+..+x^n #2434

Printing the simple geometric series and finding its sum

#### Multiple return paths in isPrime() function for prime number series #2449

Using a bool output function isPrime() which has multiple return paths for prime number check and then using this function to print a prime series for given number of terms

#### Simple descending order series #2459

Printing a descending order series – Numbers divisible by 3 from 30 to 1.

#### Pattern – Inverted right half triangle of symbol #2464

Printing the inverted right half triangle made of same symbol as per row count given by the user.

#### Pattern – Upright right half triangle of symbol #2470

Printing the upright right half triangle made of same symbol as per row count given by the user.

#### upright triangle with user given character #2482

Printing an upright triangle filled with user given character.

#### Swapping two variables using temporary third variable. #2493

Swapping of value between two integer variables using the intermediate third variable.

#### Swapping two variables without using third variable. #2497

Swapping of value between two integer variables without using the intermediate third variable.

#### Finding count of members in a linear array #2502

Finding the number of members in an array using the sizeof operator

#### Reversing an array #2506

Reversing an integer array using the swapping of members around midpoint.

#### Collecting array entries and displaying it like its formal representation #2510

Taking array entries from the user and displaying it like its formal representation as {1,2,..5}

#### String declaration and initialisation #2545

String declaration as character arrays an initialising them as individual character literals or as string literals.

#### Finding string length using the null finding technique #2551

Finding the length of an initialised character array or the c-style string using the null termination check.

#### Finding string length using the strlen() function #2556

Finding the length of an initialised character array or the c-style string using the strlen() function.

#### Getting string input from user using cin.getline #2560

Collecting string like input from the user which could be a full line.

#### Comparing length of two strings entered by the user #2565

A program to compare length of two strings entered by the user using cin.getline() and compared using strlen.

#### Comparing two strings for exact character wise match or for sort order using strcmp() #2571

A program to compare two strings entered by the user if their all characters are same or which string will come first in the sort order using the function strcmp(str1,str2)

#### gets() puts() string functions use and misuse #2606

Using gets() and puts() string function and its serious limitations

#### strcpy() and strcat() use in null terminated strings #2611

Use of functions strcpy() and strcat() on null terminated strings.

#### Reversing a null terminated string #2621

Reversing the original string given by the user and then printing it.

#### Call by reference demonstration #2647

A simple call by reference demonstration by adding something in the original value itself.

#### Function Call by Reference and Call by Value comparison #2680

A program that uses both call by reference and call by value in the same program to compare it for better understanding.

#### Variable swapping using function call by reference #2685

Swapping (Interchange) of two variable values using the call by reference technique of function arguments.

#### Global and Local Function Declaration #2689

Understanding global and local function declaration using a function declaration above main and another inside the main routine.

#### Passing null terminated string to function using array notation #2701

Program to pass by reference character array as a null terminated string to a function using the array notation using [ ].

#### Passing null terminated string to function using pointer notation #2706

Program to pass by reference character array as a null terminated string to a function using the pointer notation using *.

#### Passing integer array to a function for linear search #2733

Program to pass an integer array, length of array and the member to be found to a function and return the position of the member found.

#### Changing multiple values of integer array passed to a function #2737

A program to pass integer array to a function and change many values in it based on a condition. Then reading such values in the calling function.

#### Function returning by reference #2749

A program to demonstrate returning of a reference data type from the function.

#### Using function return by reference to modify a global array #2754

A program that neatly modifies a global array by using the function return by reference technique.

#### Structures demo program with int and char array #2767

A program using structure with two different type of variables int and char[] grouped in one structure.

#### Creating global instances or objects of structures #2777

A technique to create instances of a structure which can be used by many functions,

#### Initialising structure variables while creating instances #2795

A demonstration of initialisation of values of variables while creating the instances of the structures.

#### Effect of partial or no intialisation of structure instance variables #2799

Understanding default values in case of partial or no initialisation of structure instances.

#### Inverted triangle with user given character #2804

Printing an inverted triangle filled with user given character.

#### Upright right half triangle of numbers #2809

Print the right half upright pyramid of increasing numbers.

#### Upright right half triangle of alphabets (column-wise increasing) #2814

Print the right half upright pyramid of column wise increasing alphabets like follows –
A
A B
A B C

#### Upright right half triangle of alphabets (row-wise increasing) #2854

Print the right half upright pyramid of row wise increasing alphabets like follows –
A
B B
C C C
…………..

#### Printing the Flyod’s Triangle #2856

Printing the Flyod’s triangle of numbers which are increasing in both row and column wise fashion

#### Series of triangular numbers #2864

Program to print the triangular series like – 1 3 5 10 15 ……….

#### Finding GCD/HCF of two integer numbers #2871

Program to find Highest Common Factor (HCF), also called the Greatest Common Divisor between the two numbers entered by the user.

#### Finding LCM/SCM of two integer numbers #2874

Program to find the Least Common Multiple (LCM), also called the smallest common multiple between the two numbers entered by the user.

#### Check if Perfect Square #2884

A program to check if the given integer by the user is a perfect square of some integer number.

#### Check if Perfect Square (double to int conversion method) #2888

A program to check if the given integer by the user is a perfect square of some integer number by using the square root of double to int conversion and then comparison method.

#### Check if Triangular Number (successive summation method) #2892

Find if the given number is a triangular number by successive summation of natural numbers until it matches the given number.

#### Check if Triangular Number (perfect square testing – without sqrt) #2897

Find if the given number is a triangular number by finding if the 8*n+1 is a perfect square without using the sqrt function of the math library

#### Check if Triangular Number (perfect square testing – using rounded sqrt) #2900

Find if the given number is a triangular number by finding if the 8*n+1 is a perfect square by using the rounded square root.

#### Check if Triangular Number (perfect square testing – double to int) #2907

Find if the given number is a triangular number by finding if the 8*n+1 is a perfect square by using the double to int conversion.

#### Structure instance creation using pointer based notation #2911

A system of creating structure instances using pointer based notation or the method indicating the address location of the structure.

#### Structure instance copying #2916

Copying one instance of structure to another for the instances derived from the same structure definition

#### Case where structure instance copy is not allowed #2920

A program to explain the case where instance copying is not permitted.

#### Nesting of strucutres #2924

A program to demonstrate nested structures with one structure called within another structure.

#### Nested Structures Initialisation #2934

Program to demonstrate the initialisation process of nested structures.

#### Preparing Array of Structures #2938

Program to demonstrate how an array of structures is prepared to get entry of multiple similar type of data entries.

#### Largest of three numbers using nested ternary operator #2943

A program to demonstrate nesting of ternary operator while finding the largest of three numbers.

#### Passing Structure variables to a function #2955

Demonstration of how structure variables can be passed to function as pass-by-value or as pass-by-reference method

#### Passing structure to a function pass-by-value #2969

A program to demonstrate passing of structure to a function using pass by value method,

#### Structure passed as a reference #2979

A program to demonstrate how an structure is passed as a reference argument to a function.

#### Strings with string class declaration, initialisation and assignment #3006

A program to demonstrate declaration and initialisation of strings in c++ using the string class.

#### Finding string class string length .length() .size() .c_str() methods #3009

Program to demonstrate string class based string in c++ using different methods length() size() and conversion to c_str()

#### User input to string class based strings #3023

Collecting user input to string class string objects using cin and getline()

#### Copy and Addition (Concatenation) of string class based strings #3028

A demonstration program to see how string objects of string class are copied or concatenated one after the another.

#### Use of clear() and empty() methods of string class object #3031

Learn to use methods <string object>.clear() and <string object>.empty()

#### accessing a character of object of string class #3045

A program to show individual characters in a string class based object are accessed.

#### reversing a string object using the reverse function in algorithm lib #3049

Using the reverse() function directly along with begin() and end() iteration location setting functions of string class object

#### palindrome check on string object using the reverse function in algorithm lib #3052

Using the reverse() function on string object to check for palindrome nature of a string class object.

#### Copying an Integer Array #3091

Demonstrating how an array can be copied to another array of same size by copying each member of the array.

#### printing filtered array content #3095

Demonstrating how to print the filtered array content.

#### copying filtered array content to another array #3102

Demonstrating how to filter the array content and then copy it to another array.

#### copying filtered array content to another array by maintaining count #3106

Demonstrating how to filter the array content and then copy it to another array by maintaining the filter size count.

#### Upright Hollow Triangle with given base size #3111

Printing upright hollow triangle with given base size.

#### Downward Hollow Triangle with given base size and left offset #3116

Printing downward hollow triangle with given base size and left offset.

#### Printing a diamond pattern #3124

A program that prints a diamond pattern of stars where a size unit is given in form of half of the diamond height.

#### Printing a damru/dumbbell pattern #3128

A program that prints a damru or dumb bell pattern of stars where a size unit is given in form of half of the damru height.

#### Pascal’s Triangle Printing #3173

Printing a pascal’s triangle of given number of rows.

#### Checking for buzz number #3176

Test if a number is divisible by 7 or the last digit is 7, means whether the number is a buzz number.

#### Find prime factors of a number #3218

Finding prime factors of a number input by the user.

#### Modulus operator for integers #3589

Getting the remainder of an integer division using the modulus operator.

#### Use of setw() manipulator #4310

Demonstration of setw manipulation for setting display width

#### Testing setw() for persistence of its effect #4312

Seeing in what condition effect of setw is persistent and when it is not.

#### setf method for left and right alignment in a display field #4318

Use of setf method of cout to align content as left or right in a display field.

#### using setprecision without fixed or scientific format. #4326

setprecision to set number of digits for any decimal containing floating number.

#### Use of typedef – 1 #4341

typedef as replacement for using a friendlier name.

Understanding function overloading concept as a need to handle different data types but for exactly the same purpose.

Understanding function overloading concept as a need to handle different number of parameters

#### Same function name but different purpose #4485

Function overloading when function name is same but the objective of function is entirely different.

#### Same data types and count but signature different #4487

Function overloading when function data types are same, count is also same but signature is different.

#### typedef of a previously defined typedef #4503

second level typedef definition of a previously defined typedef.

#### typedef for arrays #4506

understanding how typedef includes array size also while defining type

#### Simple use of enumerated data type #4554

Understanding use of enumerated data type with a simple example.

#### Enumerated data type with given set of values #4565

Understanding use of enumerated data type with user given set of values and not by compiler default values.

#### Finding size of enumerated data type #4567

Understanding how enum datatype is stored in memory

#### #include directive – Preprocessor for header inclusion #4572

Understanding the purpose of include preprocessor

#### #define directive – Preprocessor for Names to constant replacement #4580

Understanding the purpose of #define pre-processor directive.

#### #define directive as Macros Expressions #4585

Understanding the purpose of #define pre-processor directive to be used as macros or use of replacement action for expressions

#### #define Macros Nesting #4587

Understanding how #define macros can be nested (use of one macros expression as a part of another macros expression)

#### Operator having many forms #4643

Demonstration of a kind of polymorphism with + operator.

#### Function having many forms #4646

Demonstration of a kind of polymorphism with multiple functions have different parameters.

#### Dynamic Polymorphism (Runtime Polymorphism) #4650

Demonstration of a kind of polymorphism action when the program is rum.

#### Child class reading parent class data member #4673

Understanding how a child class object read the parent class data member easily.

#### Child class reading parent class methods #4676

Understanding how a child class object can read the parent class methods/functions easily.

#### Assignment operator chain #5511

Here we demonstrate the assignment done in a chain fashion.

#### Multiple value assignment attempts #5571

Here we demonstrate the treatment of precedence between comma, brackets and assignment operator in a multiple value assignment scenario.

#### Finding required libraries based on functions used #5607

Ronica Jose has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

```void main()
{
double X,Times,Result;
cin>>X>>Times;
Result=pow(X,Times);
cout<<Result<<endl;
}```

#### Basic Copy Constructor and Using it #7463

Understanding copy constructor concept as a need to copy objects by passing reference of another object of same class.

#### Object Copying by Assignment or By Copy Constructor #7466

Understanding object copying by assignment or by using copy constructor call.

#### Copy Constructor Call When Passed as Value to A Function #7470

Understanding copy constructor call when class object is passed as value to a function.

#### Copy Constructor Call When Function Returns a Reference to Class Object #7473

Understanding copy constructor call when a function is returning reference to a class object.

#### Empty File Creation #7479

Creating an empty file using ofstream class

#### File Creation with fail() check #7481

Checking if file could be created after the creation object has been made along with filename parameter.

#### File Creation with ! check #7484

Checking if file could be created using !<obj> check after the creation object has been made along with filename parameter.

#### Simple pointer declaration #7503

Understanding how pointer variable is a notation for address of an entity in memory.

#### Character pointer to string literal declaration #7506

Understanding how character pointer variable is initialised with a string litereal.

#### Sum of primary diagonal members of a square matrix array #7519

Finding sum of primary diagonal (from left top to right bottom) members of a 2D of a square matrix array

#### Sum of primary diagonal members of a square matrix using 1 loop only #7521

Finding sum of primary diagonal (from left top to right bottom) members of a 2D of a square matrix array using one loop only

#### Area of Triangle using base and height #1787

Finding the area of a triangle when base and height is given

#### Integer data limits checking #2122

A program to check and understand integer data type data limits

#### Simple expression forming #1820

Forming expressions with simple variables.

#### Commenting Code #1243

Here is a simple example to show different types of comments.

#### Teens party – empty if statement #1920

Understanding the behaviour of if when nothing is done when if condition is true.

#### Displaying Multiple String Literals #1241

This program shows how multiple strings can be shown one after the other on the standard output.

#### Hello World (Variation without global namespace) #1239

This is a traditional program we always start by simply displaying some characters on standard output device. This variation uses independent namespace with related objects.

#### Linear search using array reference passing to function #1628

Search for presence of element in an integer array by using a function with a call by reference of array, size and search term.

Exam Paper Problems #### Identifying keywords and user defined identifiers #3990

( As In Exam - CBSE12A-2018 )

Write the type of C++ tokens (keywords and user defined identifiers) from the

Write the type of C++ tokens (keywords and user defined identifiers) from the following:
(i) else (ii) Long (iii) 4Queue (iv) _count

#### File and string related header files #5191

( As In Exam - CBSE12A-2018 )

The following C++ code during compilation reports errors as follows:
Er

The following C++ code during compilation reports errors as follows:
Error: ‘ofstream’ not declared
Error: ‘strupr’ not declared
Error: ‘strcat’ not declared
Error: ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

```void main()
{
ofstream FIN("WISH.TXT");
char TEXT2[]="good day";
char TEXT1[]="John!";
strupr(TEXT2);
strcat(TEXT1, TEXT2);
FIN<<TEXT1<<endl;
}```

#### Error finding, typedef and others #5195

( As In Exam - CBSE12A-2018 )

Rewrite the following C++ code after removing any/all syntactical errors with

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note : Assume all required header files are already included in the program.

```Typedef Count int;
void main()
{
Count C;
cout<<"Enter the count:";
cin>>C;
for (K = 1; K<=C; K++)
cout<< C "*" K <<endl;
}```

#### Output writing – Function – pass by reference #5197

( As In Exam - CBSE12A-2018 )

Find and write the output of the following C++ program code: Note : Assume al

Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program.

```void Revert(int &Num, int Last=2)
{
Last=(Last%2==0)?Last+1:Last-1;
for(int C=1; C<=Last; C++)
Num+=C;
}

void main()
{
int A=20,B=4;
Revert(A,B);
cout<<A<<"&"<<B<<endl;
B--;
Revert(A,B);
cout<<A<<"#"<<B<<endl;
Revert(B);
cout<<A<<"#"<<B<<endl;
}```

#### Output writing – Pointer to array #5204

( As In Exam - CBSE12A-2018 )

Find and write the output of the following C++ program code:
Note : Ass

Find and write the output of the following C++ program code:
Note : Assume all required header files are already included in the program.

```#define Modify(N) N*3+10
void main()
{
int LIST[]={10,15,12,17};
int *P=LIST, C;
for(C=3; C>=0; C--)
LIST[I]=Modify(LIST[I]);
for (C=0; C<=3; C++)
{
cout<<*P<<":";
P++;
}
}```

#### Output writing – Possible Random Numbers #5224

( As In Exam - CBSE12A-2018 )

Look at the following C++ code and find the possible output(s) from the optio

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the highest and lowest values that can be assigned in the array A.
Note :
● Assume all the required header files are already being included in the code.
● The function random(n) generates an integer between 0 and n-1.

```void main()
{
randomize();
int A, C;
for(C=0; C<4; C++)
A[C]=random(C+1)+10;
for(C=3; C>=0; C--)
cout<<A[C]<<"@";
}```

(i)   13@10@11@10@             (ii)   15\$14\$12\$10\$
(iii) 12@11@13@10@             (iv)  12@11@10@10@

( As In Exam - CBSE12A-2018 )

Which function(s) out of the following can be considered as overloaded funct

Which function(s) out of the following can be considered as overloaded function(s) in the same program? Also, write the reason for not considering the other(s) as overloaded function(s).

void Execute(char A,int B); //Function 1
void Execute(int A,char B); //Function 2
void Execute(int P=10); //Function 3
void Execute(); //Function 4
int Execute(int A); //Function 5
void Execute(int &K); //Function 6

#### Inherited Function Calling #5235

( As In Exam - CBSE12A-2018 )

Observe the following C++ code and answer the questions (i) and (ii).
N

Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.

```class FIRST
{
int Num1;
public:
void Display() //Member Function 1
{
cout<<Num1<<endl;
}
};
class SECOND: public FIRST
{
int Num2;
public:
void Display() //Member Function 2
{
cout<<Num2<<endl;
}
};
void main()
{
SECOND S;
___________________ //Statement 1
___________________ //Statement 2
}```

(i) Which Object Oriented Programming feature is illustrated by the definitions of
classes FIRST and SECOND?

(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member
Function 2 respectively using the object S.

#### Writing Class Definition #5261

( As In Exam - CBSE12A-2018 )

Write the definition of a class CONTAINER in C++ with the following descripti

Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Type // int (1 for Cone,2 for Cylinder)
– Volume // float
– CalVolume() // Member function to calculate volume as per the Type

Type Formula to calculate Volume

Public Members
– GetValues() // A function to allow user to enter value of Radius, Height and Type. Also, call
function CalVolume() from it.
– ShowAll() // A function to display Radius, Height, Type and Volume of Container

#### Class Inheritance, Member Access and Constructor #5267

( As In Exam - CBSE12A-2018 )

Answer the questions (i) to (iv) based on the following:

```class Teach

```

Answer the questions (i) to (iv) based on the following:

```class Teacher
{
int TCode;
protected:
char Name;
public:
Teacher();
void Enter(); void Show();
};
class Course
{
int ID;
protected:
Char Title;
public:
Course();
void Initiate();
void Display();
};
class Schedule: public Course, private Teacher
{
int DD,MM,YYYY;
public:
Schedule();
void Start();
void View();
};
void main()
{
Schedule S;
}```

(i) Which type of Inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
(ii) Write the names of all the members, which are directly accessible by the member
function View() of class Schedule.
(iii) Write the names of all the members, which are directly accessible by the object S
of class Schedule declared in the main() function.
(iv) What will be the order of execution of the constructors, when the object S of class
Schedule is declared inside main() function?

#### Sum of even and odd values in an array #5270

( As In Exam - CBSE12A-2018 )

Write the definition of a function SumEO(int VALUES[], int N) in C++, which

Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the sum of even values and sum of odd values of the array separately.

Example: if the array VALUES contains
25 20 22 21 53

Then the functions should display the output as:
Sum of even values = 42 (i.e 20+22)
Sum of odd values = 99 (i.e 25+21+53)

#### Printing Top Left Diagonal Half of Square Matrix Including Diagonal Members. #5274

( As In Exam - CBSE12A-2018 )

Write definition for a function UpperHalf(int Mat) in C++, which displa

Write definition for a function UpperHalf(int Mat) in C++, which displays the
elements in the same way as per the example shown below.

For example, if the content of the array Mat is as follows:

```25 24 23 22
20 19 18 17
15 14 13 12
10  9  8  7```

The function should display the content in the following format:

```25 24 23 22
20 19 18
15 14
10```

#### 2-D Array Element Address Calculation #5281

( As In Exam - CBSE12A-2018 )

Let us assume Data is a two dimensional array, which is stored in the

Let us assume Data is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element Data, if the element Data is stored at the memory location 15000.

#### Identifier or keyword writing #5297

( As In Exam - CBSE12A-2017 )

Write the type of C++ tokens (keywords and user defined identifiers) from the

Write the type of C++ tokens (keywords and user defined identifiers) from the following:

(i) new
(ii) While
(iii) case
(iv) Num_2

( As In Exam - CBSE12A-2017 )

Anil typed the following C++ code and during compilation he found three error

Anil typed the following C++ code and during compilation he found three errors as follows:
(i) Function strlen should have prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code. Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following  code

```void main()
{
char Txt[] = "Welcome";
for(int C= 0; C<strlen(Txt); C++)
Txt[C] = Txt[C]+1;
cout<<Txt<<endl;
}```

#### Code error finding #5302

( As In Exam - CBSE12A-2017 )

Rewrite the following C++ code after removing any/all syntactical errors wit

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined. Note: Assume all required header files are already being included in the program.

```void main()
{
cout<<"Enter an Alphabet:";
cin>>CH;
switch(CH)
case ‘A’ cout<<"Ant"; Break;
case ‘B’ cout<<"Bear" ; Break;
}```

#### Macro definition for array filling #5304

( As In Exam - CBSE12A-2017 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

```#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
int A,B,NUM[] = {10,23,14,54,32};
for(int CNT =4; CNT>0; CNT--)
{
A=NUM[CNT];
B=NUM[CNT-1];
cout<<Diff(A,B)<<'#';
}
}```

#### Output writing with pointer based traversing of an array #5318

( As In Exam - CBSE12A-2017 )

Find and write the output of the following C++ program code: Note: Assume al

Find and write the output of the following C++ program code: Note: Assume all required header files are already being included in the program.

```void main()
{
int *Point, Score[]={100,95,150,75,65,120};
Point = Score;
for(int L = 0; L<6; L++)
{
if((*Point)%10==0)
*Point /= 2;
else
*Point -= 2;
if((*Point)%5==0)
*Point /= 5;
Point++;
}
for(int L = 5; L>=0; L--)
cout<<Score[L]<<"*";
}```

#### Random Number Based Guessing of output of a 2D Array printing #5322

( As In Exam - CBSE12A-2017 )

Look at the following C++ code and find the possible output(s) from the

Look at the following C++ code and find the possible output(s) from the
options (i) to (iv) following it. Also, write the maximum values that can
be assigned to each of the variables N and M.

Note:

• Assume all the required header files are already being included in
the code.
• The function random(n) generates an integer between 0 and n-1
```void main()
{
randomize();
int N=random(3),M=random(4);
int DOCK = {{1,2,3},{2,3,4},{3,4,5}};
for(int R=0; R<N; R++)
{
for(int C=0; C<M; C++)
cout<<DOCK[R][C]<<" ";
cout<<endl;
}
}```

(i)
1 2 3
2 3 4
3 4 5

(ii)
1 2 3
2 3 4

(iii)
1 2
2 3

(iv)
1 2
2 3
3 4

#### Public Private Class Member #5432

What is the difference between public member and private member of a class.

What is the difference between public member and private member of a class.

#### Finding incorrect identifiers #5600

( As In Exam - CBSE12A-2016 )

Out of the following, find those identifiers, which can not be used for namin

Out of the following, find those identifiers, which can not be used for naming Variable, Constants or Functions in a C++ program:

Total*Tax, double, Case, My Name,
NeW, switch, Column31, _Amount

#### Finding required libraries based on functions used #5607

( As In Exam - CBSE12A-2016 )

Ronica Jose has started learning C++ and has typed the following program. Whe

Ronica Jose has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

```void main()
{
double X,Times,Result;
cin>>X>>Times;
Result=pow(X,Times);
cout<<Result<<endl;
}```

#### Finding and removing Syntax Errors #5610

( As In Exam - CBSE12A-2016 )

Rewrite the following C++ code after removing any/all syntactical errors with

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.

Note: Assume all required header files are already being included in the program.

```#define Formula(a,b) = 2*a+b
void main()
{
float X=3.2;Y=4.1;
Z=Formula(X,Y);
cout<<'Result='<<Z<<endl;
}```

#### 01D #5614

( As In Exam - CBSE12A-2016 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

```typedef char TEXT;
void JumbleUp(TEXT T)
{
int L=strlen(T);
for (int C=0;C<L1;C+=2)
{
char CT=T[C];
T[C]=T[C+1]
T[C+1]=CT;
}
for (C=1;C<L;C+=2)
if (T[C]>='M' && T[C]<='U')
T[C]=’@’;
}
void main()
{
TEXT Str="HARMONIOUS";
JumbleUp(Str);
cout<<Str<<endl;
}```

#### Output writing parameterized class methods #5619

( As In Exam - CBSE12A-2016 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```class Share
{
long int Code;
float Rate;
int DD;
public:
Share(){Code=1000;Rate=100;DD=1;}
void GetCode(long int C,float R)
{
Code=C;
Rate=R;
}
void Update(int Change,int D)
{
Rate+=Change;
DD=D;
}
void Status()
{
cout<<"Date:"<<DD<<endl;
cout<<Code<<"#"<<Rate<<endl;
}
};
void main()
{
Share S,T,U;
S.GetCode(1324,350);
T.GetCode(1435,250);
S.Update(50,28);
U.Update(25,26);
S.Status();
T.Status();
U.Status();
}```

#### Random picking from string array #5621

( As In Exam - CBSE12A-2016 )

Look at the following C++ code and find the possible output(s) from the optio

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable PICKER.

Note:
– Assume all the required header files are already being included in the code.
– The function random(n) generates an integer between 0 and n-1

```void main()
{
randomize().
int PICKER.
PICKER=1+random(3).
char COLOR[]={"BLUE","PINK","GREEN","RED"}.
for(int I=0;I<=PICKER;I++)
{
for(int J=0;J<=I;J++)
cout<<COLOR[J].
cout<<endl.
}
}
```
(i) (ii) (iii) (iv)
PINK BLUE GREEN BLUE
PINKGREEN BLUEPINK GREENRED BLUEPINK
PINKGREENRED BLUEPINKGREEN BLUEPINKGREEN
BLUEPINKGREENRED

#### Characteristics of OOP #5629

( As In Exam - CBSE12A-2016 )

Write any four important characteristics of Object Oriented Programming? Give

Write any four important characteristics of Object Oriented Programming? Give example of any one of the characteristics using C++.

#### OOPs Concept Identification and Destructor Calling Identification #5632

( As In Exam - CBSE12A-2016 )

Observe the following C++ code and answer the questions (i) and (ii). Assume

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included:

```class BOOK
{
long Code ;
char Title;
float Price;
public:
BOOK() //Member Function 1
{
cout<<”Bought”<<endl;
Code=10;strcpy(Title,”NoTitle”);Price=100;
}
BOOK(int C,char T[],float P) //Member Function 2
{
Code=C;
strcpy(Title,T);
Price=P;
}
void Update(float P) //Member Function 3
{
Price+=P;
}
void Display() //Member Function 4
{
cout<<Code<<”:”<<Title<<”:”<<Price<<endl;
}
~BOOK()        //Member Function 5
{
}
};
void main()                    //Line 1
{                              //Line 2
BOOK B,C(101,"Truth",350};   //Line 3
for (int I=0;I<4;I++)        //Line 4
{                            //Line 5
B.Update(50);C.Update(20); //Line 6
B.Display();C.Display();   //Line 7
}                            //Line 8
}                              //Line 9
```

(i) Which specific concept of object oriented programming out of the following is illustrated by member Function 1 and member Function 2 combined together?

• Data Encapsulation
• Polymorphism
• Inheritance
• Data Hiding

(ii) How many times the message ”Book Discarded!” will be displayed after executing the above C++ code? Out of Line 1 to Line 9, which line is responsible to display the message ”Book Discarded!”

#### Defining Class Based on Data Members and Functions Given #5634

( As In Exam - CBSE12A-2016 )

Write the definition of a class CITY in C++ with following description:

<

Write the definition of a class CITY in C++ with following description:

Private Members

Ccode         //Data member for City Code (an integer)
CName      //Data member for City Name (a string)
Pop              //Data member for Population (a long int)
KM              //Data member for Area Coverage (a float)
Density      //Data member for Population Density (a float)
DenCal()   //A member function to calculate Density as Pop/KM

Public Members
Record()   //A function to allow user to enter values of Acode,Name,Pop,KM and call DenCal() function
View() //A function to display all the data members. Also display a message ”Highly Populated City”
if the Density is more than 10000

#### Inheritance Type, Data and Function Accessibility Identification #5638

( As In Exam - CBSE12A-2016 )

Answer the questions (i) to (iv) based on the following:

```class ITEM

```

Answer the questions (i) to (iv) based on the following:

```class ITEM
{
int Id;
char IName;
protected:
float Qty;
public:
ITEM();
void Enter(); void View();
};
{
int DCode;
protected:
char Manager;
public:
void Enter();
void View();
};
class SALEPOINT : public ITEM,private TRADER
{
char Name,Location;
public :
SALEPOINT();
void EnterAll();
void ViewAll();
};

```

(i) Which type of Inheritance out of the following is illustrated in the above example?

-Single Level Inheritance
-Multi Level Inheritance
-Multiple Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class SALEPOINT.

(iii) Write the names of all the member functions, which are directly accessible by an object of class SALEPOINT.

(iv) What will be the order of execution of the constructors, when an object of class SALEPOINT is declared?

#### 03A #5652

( As In Exam - CBSE12A-2016 )

Write the definition of a function FixSalary(float Salary[], int N) in C++, w

Write the definition of a function FixSalary(float Salary[], int N) in C++, which should modify each element of the array Salary having N elements, as per the following rules:

Existing Salary Values Required Modification in Value
If less than 100000 Add 35% in the existing value
If >=100000 and <20000 Add 30% in the existing value
If >=200000 Add 20% in the existing value

#### Finding relative address in 2D Array #5661

( As In Exam - CBSE12A-2016 )

R is a two dimensional array, which is stored in the memory along the

R is a two dimensional array, which is stored in the memory along the row with each of its element occupying 8 bytes, find the address of the element R, if the element R is stored at the memory location 45000.

#### 03C #5665

( As In Exam - CBSE12A-2016 )

Write the definition of a member function DELETE() for a class QUEUE in C++,

Write the definition of a member function DELETE() for a class QUEUE in C++, to remove a product from a dynamically allocated Queue of products considering the following code is already written as a part of the program.

```struct PRODUCT
{
int PID; char PNAME;
PRODUCT *Next;
};
class QUEUE
{
PRODUCT *R,*F;
public:
QUEUE(){R=NULL;F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};```

#### Function to display middle column of 2D Array #5668

( As In Exam - CBSE12A-2016 )

Write definition for a function DISPMID(int A[],int R,int C) in C++ to dis

Write definition for a function DISPMID(int A[],int R,int C) in C++ to display the elements of middle row and middle column from a two dimensional array A having R number of rows and C number of columns.
For example, if the content of array is as follows:

 215 912 516 401 515 103 901 921 802 601 285 209 609 360 172

The function should display the following as output
103 901 921 802 601
516 921 609

#### 03E #5674

( As In Exam - CBSE12A-2016 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.

P/(QR)*S+T

#### 04A #5681

( As In Exam - CBSE12A-2016 )

Write function definition for DISP3CHAR() in C++ to read the content of a tex

Write function definition for DISP3CHAR() in C++ to read the content of a text file KIDINME.TXT, and display all those words, which have three characters in it.
Example: If the content of the file KIDINME.TXT is as follows:

```When I was a small child, I used to play in the garden with my grand mom.
Those days were amazingly funful and I remember all the moments of that time```

The function DISP3CHAR() should display the following:

`was the mom and all the`

#### 04B #5686

( As In Exam - CBSE12A-2016 )

Write a definition for function ONOFFER( ) in C++ to read each object of a bi

Write a definition for function ONOFFER( ) in C++ to read each object of a binary file TOYS.DAT, find and display details of those toys, which has status as “ÖN OFFER”. Assume that the file TOYS.DAT is created with the help of objects of class TOYS, which is defined below:

```class TOYS
{
int TID;char Toy,Status; float MRP;
public:
void Getinstock()
{
cin>>TID;gets(Toy);gets(Status);cin>>MRP;
}
void View()
{
cout<<TID<<”:”<<Toy<<”:”<<MRP<<””:”<<Status<<endl;
}
char *SeeOffer() { return Status; }
};```

#### Binary file position determinations using tellg() #5689

( As In Exam - CBSE12A-2016 )

Find the output of the following C++ code considering that the binary file C

Find the output of the following C++ code considering that the binary file CLIENT.DAT exists on the hard disk with a data of 1000 clients.

```class CLIENT
{
int Ccode;char CName;
public:
void Register();void Display();
};
void main()
{
fstream CFile;
CFile.open(“CLIENT.DAT”,ios::binary|ios::in);
CLIENT C;
cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
CFile.close();
}```

#### 03D #5714

( As In Exam - CBSE12A-2018 )

Write the definition of a member function AddPacket() for a class QUEUE in C+

Write the definition of a member function AddPacket() for a class QUEUE in C++, to remove/delete a Packet from a dynamically allocated QUEUE of Packets considering the following code is already written as a part of the program.

```struct Packet
{
int PID;
};
class QUEUE
{
Packet *Front, *Rear;
public:
QUEUE(){Front=NULL;Rear=NULL;}
void DeletePacket();
~QUEUE();
};```

#### 03E #5717

( As In Exam - CBSE12A-2018 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:
U * V + (W – Z) / X

#### 04A #5722

( As In Exam - CBSE12A-2018 )

A text file named MATTER.TXT contains some text, which needs to be displayed�

A text file named MATTER.TXT contains some text, which needs to be displayed such that every next character is separated by a symbol ‘#’. Write a function definition for HashDisplay () in C++ that would display the entire content of the file MATTER.TXT in the desired format.
Example:
If the file MATTER.TXT has the following content stored in it:
THE WORLD IS ROUND
The function HashDisplay () should display the following content:
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#

#### 04B #5726

( As In Exam - CBSE12A-2018 )

Write a definition for function TotalTeachers( ) in C++ to read each object o

Write a definition for function TotalTeachers( ) in C++ to read each object of a binary file SCHOOLS.DAT, find the total number of teachers, whose data is stored in the file and display the same. Assume that the file SCHOOLS.DAT is created with the help of objects of class SCHOOLS, which is defined below:

```class SCHOOLS
{
int SCode; // School Code
char SName; // School Name
int NOT; // Number of Teachers in the school
public:
void Display()
{cout<<SCode<<"#"<<SName<<"#"<<NOT<<endl;}
int RNOT(){return NOT;}
};```

#### 04C #5730

( As In Exam - CBSE12A-2018 )

Find the output of the following C++ code considering that the binary file SC

Find the output of the following C++ code considering that the binary file SCHOOLS.DAT exists on the hard disk with the following records of 10 schools of the class SCHOOLS as declared in the previous question (4 b).

SCode SName NOT
1001 Brains School 100
1003 Child Life School 115
1002 Care Share School 300
1006 Educate for Life School 50
1004 Holy Education School 140
1010 Rahmat E Talim School 95
1008 Innovate Excel School 300
1011 Premier Education School 200
1012 Uplifted Minds School 100

```void main()
{
fstream SFIN;
SFIN.open("SCHOOLS.DAT",ios::binary|ios::in);
SCHOOLS S;
SFIN.seekg(5*sizeof(S));
S.Display();
cout<<"Record :"<<SFIN.tellg()/sizeof(S) + 1<<endl;
SFIN.close();
}```

#### 02A #5752

( As In Exam - CBSE12A-2017 )

Differentiate between protected and private members of a class in context of�

Differentiate between protected and private members of a class in context of Object Oriented Programming. Also give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.

#### OOPs Concept Identification and Writing Object Declaration Statements #5756

( As In Exam - CBSE12A-2017 )

Observe the following C++ code and answer the questions (i) and (ii).
N

Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.

```class TEST
{
long TCode;
char TTitle;
float Score;
public:
TEST()    //Member Function 1
{
TCode=100;strcpy(TTitle,”FIRST Test”);Score=0;
}
TEST(TEST &T)    //Member Function 2
{
TCode=E.TCode+1;
strcpy(TTitle,T.TTitle);
Score=T.Score;
}
};
void main()
{
___________________     //Statement 1
___________________     //Statement 2
}```

(i) Which Object Oriented Programming feature is illustrated by the Member Function 1 and Member Function 2 together in the class TEST?

(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.

#### 02C #5759

( As In Exam - CBSE12A-2017 )

Write the definition of a class BOX in C++ with following description:

Write the definition of a class BOX in C++ with following description:
Private Members
– BoxNumber // data member of integer type
– Side // data member of float type
– Area // data member of float type
– ExecArea() // Member function to calculate and assign
// Area as Side * Side
Public Members
– GetBox() // A function to allow user to enter values of
// BoxNumber and Side. Also, this
// function should call ExecArea() to calculate
// Area
– ShowBox() // A function to display BoxNumber, Side
// and Area

#### Finding Type and Member Accessibility #5762

( As In Exam - CBSE12A-2017 )

Answer the questions (i) to (iv) based on the following:

```class First

```

Answer the questions (i) to (iv) based on the following:

```class First
{
int X1;
protected:
float X2;
public:
First();
void Enter1(); void Display1();
};
class Second : private First
{
int Y1;
protected:
float Y2;
public:
Second();
void Enter2();
void Display();
};
class Third : public Second
{
int Z1;
public:
Third();
void Enter3();
void Display();
};
void main()
{
Third T;           //Statement 1
__________________;  //Statement 2
}```

(i) Which type of Inheritance out of the following is illustrated in the above example? Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

(ii) Write the names of all the member functions, which are directly accessible by the object T of class Third as declared in main() function.

(iii) Write Statement 2 to call function Display() of class Second from the object T of class Third.

(iv) What will be the order of execution of the constructors, when the object T of class Third is declared inside main()?

#### 03A #5764

( As In Exam - CBSE12A-2017 )

Write the definition of a function AddUp(int Arr[], int N) in C++, in which a

Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even positions (i.e. 0,2,4,…) of the array should be added with the content of the element in the next position and odd positions (i.e. 1,3,5,…) elements should be incremented by 10.
Example: if the array Arr contains

 23 30 45 10 15 25

Then the array should become

 53 40 55 20 40 35

NOTE:

• The function should only alter the content in the same array.
• The function should not copy the altered content in another array.
• The function should not display the altered content of the array.
• Assuming, the Number of elements in the array are Even.

#### Sum of middle column of 2D Matrix #5769

( As In Exam - CBSE12A-2017 )

Write a definition for a function SUMMIDCOL(int MATRIX[],int N,int M) in

Write a definition for a function SUMMIDCOL(int MATRIX[],int N,int M) in C++, which finds the sum of the middle column’s elements of the MATRIX (Assuming N represents number of rows and M represents number of columns, which is an odd integer).
Example: if the content of array MATRIX having N as 5 and M as 3 is as follows:

 1 2 1 2 1 4 3 4 5 4 5 3 5 3 2

The function should calculate the sum and display the following:
Sum of Middle Column: 15

#### 2-D Array Element Address Calculation #5772

( As In Exam - CBSE12A-2017 )

ARR is a two-dimensional array, which is stored in the memory along t

ARR is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR, if the element ARR is stored at the memory location 35000.

#### 03D #5775

( As In Exam - CBSE12A-2017 )

Write the definition of a member function PUSHGIFT() for a class STACK in C++

Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a GIFT in a dynamically allocated stack of GIFTs considering the following code is already written as a part of the program:

```struct GIFT
{
};
class STACK
{
public:
STACK(){TOP=NULL;}
~STACK();
};```

#### 03E #5777

( As In Exam - CBSE12A-2017 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:
X – ( Y + Z ) / U * V

#### 04A #5783

( As In Exam - CBSE12A-2017 )

Polina Raj has used a text editing software to type some text in an article.

Polina Raj has used a text editing software to type some text in an article. After saving the article as MYNOTES.TXT , she realised that she has wrongly typed alphabet K in place of alphabet C everywhere in the article. Write a function definition for PURETEXT() in C++ that would display the corrected version of the entire article of the file MYNOTES.TXT with all the alphabets “K” to be displayed as an alphabet “C” on screen .
Note: Assuming that MYNOTES.TXT does not contain any C alphabet otherwise.
Example:
If Polina has stored the following content in the file MYNOTES.TXT :

 I OWN A KUTE LITTLE KAR. I KARE FOR IT AS MY KHILD.

The function PURETEXT() should display the following content:

 I OWN A CUTE LITTLE CAR. I CARE FOR IT AS MY CHILD.

#### 04B #5788

( As In Exam - CBSE12A-2017 )

Write a definition for function COUNTPICS ( ) in C++ to read each object of a

Write a definition for function COUNTPICS ( ) in C++ to read each object of a binary file PHOTOS.DAT, find and display the total number of PHOTOS of type PORTRAIT. Assume that the file PHOTOS.DAT is created with the help of objects of class PHOTOS, which is defined below:

```class PHOTOS
{
int PCODE;
char PTYPE;//Photo Type as “PORTRAIT”,”NATURE”
public:
void ENTER()
{
cin>>PCODE;gets(PTYPE);
}
void SHOWCASE()
{
cout<<PCODE<<":"<<PTYPE<<endl;
}
char *GETPTYPE(){return PTYPE;}
};```

#### 04C #5793

( As In Exam - CBSE12A-2017 )

Find the output of the following C++ code considering that the binary file C

Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the hard disk with a data of 200 clients.

```class CLIENTS
{
int CCode;char CName;
public:
void REGISTER();void DISPLAY();
};
void main()
{
fstream File;
File.open("CLIENTS.DAT",ios::binary|ios::in);
CLIENTS C;
File.seekg(6*sizeof(C));
cout<<"Client Number:"<<File.tellg()/sizeof(C) + 1;
File.seekg(0,ios::end);
cout<<" of "<<File.tellg()/sizeof(C)<<endl;
File.close();
}```

#### 01A #5825

( As In Exam - CBSE12D-2015 )

Find the correct identifiers out of the following, which can be used for nam

Find the correct identifiers out of the following, which can be used for naming variable, constants or functions in a C++ program: While, for, Float, new, 2ndName, A%B, Amount2, _Counter

( As In Exam - CBSE12D-2015 )

Observe the following program very carefully and write the names of those he

Observe the following program very carefully and write the names of those header file(s), which are essentially needed to compile and execute the following program successfully:

```typedef char TEXT;
void main()
{
TEXT Str[] = "Peace is supreme";
int Index=0;
while (Str[Index]!='\0')
if (isupper(Str[Index]))
Str[Index++]='#';
else
Str[Index++]='*';
puts(str);
}```

#### 01C #5831

( As In Exam - CBSE12D-2015 )

Observe the following C++ code very carefully and rewrite it after removing

Observe the following C++ code very carefully and rewrite it after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

```#Define float Max=70.0;
void main()
{
int Speed
char Stop='N';
cin>>Speed;
if Speed>Max
Stop='Y';
cout<<Stop<<end;
}```

#### Output Writing – passing integers as ref and as def value #5834

( As In Exam - CBSE12D-2015 )

Write the output of the following C++ program code:
Note: Assume all re

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program .

```void Position (int &C1, int C2=3)
{
C1+=2;
C2+=2;   //Original paper had this incorrectly written as Y
}
void main()
{
int P1=20, P2=4;
Position(P1);
cout<<P1<<","<<P2<<endl;
Position(P2,P1);
cout<<P1<<","<<P2<<endl;
}```

#### 01E #5837

( As In Exam - CBSE12D-2015 )

Write the output of the following C++ program code:
Note: Assume all th

Write the output of the following C++ program code:
Note: Assume all the required header files are already being included in the program.

```class Calc
{
int Bonus;
public:
void Down(int G)
{
}
Void Up(int G)
{
Bonus++;
}
void Show()
{
}
};
void main()
{
Calc c;
C.Down(2);
C.Show();
C.Up(7);
C.Show();
C.Down(2)
C.Show();
}```

#### 01F #5840

( As In Exam - CBSE12D-2015 )

Study the following program and select the possible output(s)from the option

Study the following program and select the possible output(s)from the option (i) to (iv) following it. Also write the maximum and the minimum values that can be assigned to the variable NUM.
Note:

– Assume all required header files are already being includedin the program.
– random(n) function generates an integer between 0 and n-1.

```void main()
{
randomize();
int NUM;
NUM=random(3)+2;
char TEXT[]=”ABCDEFGHIJK”;
for (int I=1;I<=NUM; I++)
{
for (int J=NUM;J<=7;J++)
cout<<TEXT[J];
cout<<end1;
}
}```
```(i)FGHI    (ii) BCDEFGH   (iii) EFGH   (iv) CDEFGH
FGHI         BCDEFGH         EFGH        CDEFGH
FGHI                         EFGH
FGHI                         EFGH```

#### Copy Constructor Definition and Example #5844

( As In Exam - CBSE12D-2015 )

What is a copy constructor? Give a suitable example in C++ to illustrate wit

What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class and a declaration of an object with the help of it .

#### 02B #5848

( As In Exam - CBSE12D-2015 )

Observe the following C++ code and answer the questions (i) and (ii) :

Observe the following C++ code and answer the questions (i) and (ii) :

```class Traveller
{
long PNR;
char TName;
public :
Traveller()                  //Function 1
void Book(long P,char N[])   //Function 2
{PNR = P; strcpy(TName, N);}
void Print()                 //Function 3
{cout<<PNR << TName <<endl;}
~Traveller()                 //Function 4
{cout<<"Booking cancelled!"<<endl;}
};```

(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:

```v oid main{)
{
Traveller T;
_____________ //Line 1
_____________ //Line 2
}//Stops here```

(ii) Which function will be executed at }//Stops here? What is this
function referred as ?

#### 02C #5863

( As In Exam - CBSE12D-2015 )

Write the definition of a class PlC in C++ with following description:

Write the definition of a class PlC in C++ with following description:
Private Members

```Pno       //Data member for Picture Number (an integer)
Category  //Data member for Picture Category (a string)
Location  //Data member for Exhibition Location (a string)
FixLocation  //A member function to assign
//Exhibition Location as per category
//as shown in the following table```
 Category Location Classic Amina Modern Jim Plaq Antique Ustad Khan
```Public Members
Enter()     //A function to allow user to enter values
//Pno, category and call FixLocation() function
SeeAll()    //A function to display all the data members```

#### 02D #5866

( As In Exam - CBSE12D-2015 )

Answer the question (i) to (iv) based on the following:

```class Exteri

```

Answer the question (i) to (iv) based on the following:

```class Exterior
{
int OrderId;
protected:
public:
Exterior();
void Book();
void View();
};
class Paint:public Exterior
{
int WallArea,ColorCode;
protected:
char Type;
public:
Paint() ;
void PBook();
void PView();
};
class Bill:public Paint
{
float Charges;
void Calculate();
public:
Bill() ;
void Billing() ;
void Print() ;
};```

(i) Which type of Inheritance out of the following is illustrated in the above example?
-Single Level Inheritance
-Multi Level Inheritance
-Multiple Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class Paint.

(iii) Write the names of all the member functions, which are directly accessible from an object of class Bill.

(iv) What will be the order of execution of the constructors, when an object of class Bill is declared?

#### 03A #5871

( As In Exam - CBSE12D-2015 )

Write the definition of a function Alter(int A[], int N) in C++, which should

Write the definition of a function Alter(int A[], int N) in C++, which should change all the multiples of 5 in the array to 5 and rest of the elements as 0. For example, if an array of 10 integers is as follows:

 A A A A A A A A A A 55 43 20 16 39 90 83 40 48 25

After executing the function, the array content should be changed as follow:

 A A A A A A A A A A 5 0 5 0 0 5 0 5 0 5

#### 2-D Array Element Address Calculation #5873

( As In Exam - CBSE12D-2015 )

A two dimensional array P  is stored in the memory along the row wit

A two dimensional array P  is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element P ,if the element P  is stored at the memory location 15000.

#### 03C #5878

( As In Exam - CBSE12D-2015 )

Write the definition of a member function Pop() in C++, to delete a book fro

Write the definition of a member function Pop() in C++, to delete a book from a dynamic stack of TEXTBOOKS considering the following code is already included in the program.

```struct TEXTBOOKS
{
char ISBN; char TITLE;
};
class STACK
{
TEXTBOOKS *Top;
public:
STACK() {Top=NULL;}
void Push();
void Pop();
~STACK();
};```

#### Reversing each column in a 2D Matrix #5881

( As In Exam - CBSE12D-2015 )

Write a function REVCOL (int P[], int N, int M) in C++to display the cont

Write a function REVCOL (int P[], int N, int M) in C++to display the content of a two dimensional array, with each column content in reverse order.
Note: Array may contain any number of rows.
For example, if the content of array is as follows:

 15 12 56 45 51 13 91 92 87 63 11 23 61 46 81

The function should display output as:

```11      23     61    46    81
13      91     92    87    63
15      12     56    45    51```

#### 03E #5885

( As In Exam - CBSE12D-2015 )

Convert the following infix expression to its equivalent postfix expression,

Convert the following infix expression to its equivalent postfix expression, showing the stack contents for each step of conversion.
X / Y + U* (V-W)

#### 04A #5890

( As In Exam - CBSE12D-2015 )

Write function definition for SUCCESS () in C++ to read the content of a text

Write function definition for SUCCESS () in C++ to read the content of a text file STORY.TXT count the presence of world STORY and display the number of occurrence of this word.
Note :
-The word STORY should be an independent word
-Ignore type cases (i.e. lower/upper case)
Example: If the content of the file Story.TXT is as follows:

```Success shows others that we can do it.
It is possible to achieve success with hard work. Lot of money does not mean SUCCESS.```

The function SUCCESS () should display the following:

`3`

#### 04B #5892

( As In Exam - CBSE12D-2015 )

Write a definition for function Economic() in C++ to read each record of a b

Write a definition for function Economic() in C++ to read each record of a binary file ITEMS.DAT, find and display those items, which costs less than 2500. Assume that the file ITEMS.DAT is created with the help of objects of class ITEMS, which is defined below:

```class ITEMS
{
public :
void Get()
{
}
void See()
{
}
float GetCost() {return Cost;}.
};```

#### Finding position in binary file using tellg() #5895

( As In Exam - CBSE12D-2015 )

Find the output of the following C++ code considering that the binary file C

Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the hard disk with records of 100 members.

```class CLIENTS
{
int Cno;char Name;
public :
void In(); void Out();
};
void main{)
{
fstream CF;
CF.open("CLIENTS.DAT",ios:: binary| ios::in) ;
CLIENTS C;
int POS=CF.tellg()/sizeof(C);
cout<<"PRESENT RECORD:"<<POS<<endl;
CF.close() ;
}```

#### C05A #5897

( As In Exam - CBSE12D-2015 )

Observe the following table carefully and write the names of the most approp

Observe the following table carefully and write the names of the most appropriate columns, which can be considered as
(i) candidate keys and (ii) primary key.

Id Product Qty Price Transaction Date
101 Plastic Folder 12” 100 3400 2014-12-14
104 Pen Stand Standard 200 4500 2015-01-31
105 Stapler Medium 250 1200 2015-02-28
109 Punching Machine Big 200 1400 2015-03-12
103 Stapler Mini 100 1500 2015-02-02

#### 01A-2015 #5928

( As In Exam - CBSE12A-2015 )

Find the correct identifiers out of the following, which can be used for nam

Find the correct identifiers out of the following, which can be used for naming Variable, Constants or Functions in a C++ program:
For, while, INT, NeW, delete, 1stName, Add+Subtract, name1

( As In Exam - CBSE12A-2015 )

Observe the following program very carefully and write the name of those head

Observe the following program very carefully and write the name of those header file (s), which are essentially needed to compile and execute the following program successfully:

typedef char STRING;
void main()
{
STRING Txt[] = “We love Peace”;
int Count=0;
while (Txt[Count]!=’\0′)
if (isalpha(Txt[Count]))
Txt[Count++]=’@’ ;
else
Txt[Count++]=’#’ ;
puts (Txt) ;
}

#### 01C-2015 #5933

( As In Exam - CBSE12A-2015 )

after removing any/all syntactical errors with each correction underlined.

after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

```#Define float MaxSpeed=60.5;
void main()
{
int MySpeed
cin»MySpeed;
if MySpeed>MaxSpeed
}```

#### Output Writing – passing integers as ref and as def value #5935

( As In Exam - CBSE12A-2015 )

Write the output of the following C++ program code:
Note: Assume all re

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```void Location(int &X,int Y=4)
{
Y+=2;
X+=Y;
}
void main()
{
int PX=l0,PY=2;
Location(PY) ;
cout<<PX<<","<<PY<<endl ;
Location(PX,PY);
cout<<PX<<","<<PY<<endl ;
}```

#### 01E-2015 #5938

( As In Exam - CBSE12A-2015 )

Write the output of the following C++ program code:
Note: Assume all re

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```class Eval
{
char Level;
int Point;
public:
Eval() {Level='E';Point=0;}
void Sink(int L)
{
Level=L;
}
void Float(int L)
{
Level += L;
Point++;
}
void Show()
{
cout<<Level<<"#"<<Point<<endl;
}
};
void main()
{
Eval E;
E.Sink(3);
E.Show();
E.Float(7);
E.Show();
E.Sink(2);
E.Show();
}```

#### 01F-2015 #5940

( As In Exam - CBSE12A-2015 )

Study the following program and select the possible output(s) from the optio

Study the following program and select the possible output(s) from the option (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable VAL.
Note:
– Assume all required header files are already being included inthe program.
– random(n) function generates an integer between 0 and n-1.

```void main()
{
randomize();
int VAL;
VAL=random(3)+2;
char GUESS[]="ABCDEFGHIJK";
for (int I=1;I<=VAL;I++)
{
for(int J=VAL;J<=7;J++)
cout<<GUESS[J];
cout<<endl;
}
}

(i)       (ii)      (iii)      (iv)
BCDEFGH   CDEFGH    EFGH       FGHI
BCDEFGH   CDEFGH    EFGH       FGHI
EFGH       FGHI
EFGH       FGHI```

#### Copy Constructor Definition and Example #5943

( As In Exam - CBSE12A-2015 )

What is a copy constructor? Give a suitable example in C++ to illustrate wit

What is a copy constructor? Give a suitable example in C++ to illustrate with its definition within a class and a declaration of an object with the help of it.

#### 02B-2015 #5945

( As In Exam - CBSE12A-2015 )

Observe the following C++ code and answer the questions (i) and (ii) :

<

Observe the following C++ code and answer the questions (i) and (ii) :

```class Passenger
{
long PNR;
char Name  ;
public:
Passenger()                 //Function 1

void Book(long P,char N[])  //Function 2
{ PNR = P; strcpy(Name, N); }

void Print()                //Function 3
{ cout«PNR << Name <<endl; }

~Passenger()                //Function 4
{ cout<<"Booking cancelled!"<<endl; }
};```

(i) Fill in the blank statements in Line 1 and Line 2 to execute Function 2 and Function 3 respectively in the following code:

```void main()
{
Passenger P;
___________ //Line 1
___________ //Line 2
}//Ends here```

(ii) Which function will be executed at } //Ends here? What is this function referred as ?

#### 02C-2015 #5947

( As In Exam - CBSE12A-2015 )

Write the definition of a class Photo in C++ with following description:

Write the definition of a class Photo in C++ with following description:

```Private Members
Pno        //Data member for Photo Number
(an integer)
Category   //Data member for Photo Category
(a string)
Exhibit    //Data member for Exhibition Gallery
(a string)
FixExhibit //A member function to assign
//Exhibition Gallery as per Category
//as shown in the following table
Category  Exhibit
Antique   Zaveri
Modern    Johnsen
Classic   Terenida

Public Members
Register()  //A function to allow user to enter
//values
//Pno,Category and call FixExhibit()
//function
ViewAll()   //A function to display all the data
//members```

#### 02D-2015 #5953

( As In Exam - CBSE12A-2015 )

Answer the questions (i) to (iv) based on the following:

```class Inter

```

Answer the questions (i) to (iv) based on the following:

```class Interior
{
int OrderId;
protected:
public:
Interior();
void Book(); void View();
};
class Painting:public Interior
{
int WallArea,ColorCode;
protected:
char Type;
public:
Painting();
void PBook();
void PView();
};
class Billing:public Painting
{
float Charges;
void Calculate();
public:
Billing();
void Bill();
void BillPrint();
};```

(i) Which type of Inheritance out of the following is illustrated in the above example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance

(ii) Write the names of all the data members, which are directly accessible from the member functions of class Painting.

(iii) Write the names of all the member functions, which are directly accessible from an object of class Billing.

(iv) What will be the order of execution of the constructors, when an object of class Billing is declared?

#### 03A-2015 #5957

( As In Exam - CBSE12A-2015 )

Write the definition of a function Change(int P[], int N) in C++, which shoul

Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as follows:

 P P P P P P P P P P 100 43 20 56 32 91 80 40 45 21

After executing the function, the array content should be changed as follows:

 P P P P P P P P P P 10 1 10 1 1 1 10 10 1 1

#### 2-D Array Element Address Calculation #5959

( As In Exam - CBSE12A-2015 )

A two dimensional array ARR is stored in the memory along the row wi

A two dimensional array ARR is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR, if the element ARR  is stored at the memory location 15000.

#### 03C-2015 #5962

( As In Exam - CBSE12A-2015 )

Write the definition of a member function PUSH() in C++, to add a new book i

Write the definition of a member function PUSH() in C++, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program:

```struct BOOKS
{
char ISBN, TITLE;
};
class STACK
{
BOOKS *Top;
public:
STACK()
{Top=NULL;}
void PUSH();
void POP();
~STACK();
};```

#### Reversing each row of a 2D array #5964

( As In Exam - CBSE12A-2015 )

Write a function REVROW(int P[],int N, int M) in C++ to display the conten

Write a function REVROW(int P[],int N, int M) in C++ to display the content of a two dimensional array, with each row content in reverse order.
For example, if the content of array is as follows:

 15 12 56 45 51 13 91 92 87 63 11 23 61 46 81

The function should display output as:
51 45 56 12 15
63 87 92 91 13
81 46 61 23 81

#### 03E-2015 #5967

( As In Exam - CBSE12A-2015 )

Convert the following infix expression to its equivalent Postfix expression,

Convert the following infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
U * V + R/ (S-T)

#### 04A-2015 #5973

( As In Exam - CBSE12A-2015 )

Write function definition for TOWER() in C++ to read the content of a text fi

Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of this word.
Note :
‐ The word TOWER should be an independent word
‐ Ignore type cases (i.e. lower/upper case)
Example: If the content of the file WRITEUP.TXT is as follows:

 Tower of hanoi is an interesting problem. Mobile phone tower is away from here. Views from EIFFEL TOWER are amazing.

The function TOWER () should display the following:

 3

#### 04B-2015 #5977

( As In Exam - CBSE12A-2015 )

Write a definition for function COSTLY() in C++ to read each record of a bina

Write a definition for function COSTLY() in C++ to read each record of a binary file GIFTS.DAT, find and display those items, which are priced more that 2000. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:

```class GIFTS
{
int CODE;char ITEM; float PRICE;
public:
void Procure()
{
cin>>CODE; gets(ITEM);cin>>PRICE;
}
void View()
{
cout<<CODE<<":"<<ITEM<<":"<<PRICE<<endl;
}
float GetPrice() {return PRICE;}
};```

#### 04C-2015 #5979

( As In Exam - CBSE12A-2015 )

Find the output of the following C++ code considering that the binary file M

Find the output of the following C++ code considering that the binary file MEMBER.DAT exists on the hard disk with records of 100 members:

```class MEMBER
{
int Mno; char Name;
public:
void In();void Out();
};
void main()
{
fstream MF;
MF.open("MEMBER.DAT”,ios::binary|ios::in);
MEMBER M;
int POSITION=MF.tellg()/sizeof(M);
cout<<"PRESENT RECORD:"<<POSITION<<endl;
MF.close();
}```

#### 01A-2017 #6004

( As In Exam - CBSE12D-2017 )

Write the type of C++ tokens (keywords and user defined identifiers) from the

Write the type of C++ tokens (keywords and user defined identifiers) from the
following:
(i) For
(ii) delete
(iii) default
(iv) Value

#### 01B-2017 #6006

( As In Exam - CBSE12D-2017 )

Anil typed the following C++ code and during compilation he found four errors

Anil typed the following C++ code and during compilation he found four errors as follows:
(i) Function strlen should have a prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
(iv) Function getchar should have a prototype
On asking his teacher told him to include necessary header files in the code.
Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code:

```void main()
{
char S[] = "Hello";
for(int i = 0; i<strlen(S); i++)
S[i] = S[i]+1;
cout<<S<<endl;
getchar();
}```

#### 01C-2015 #6008

( As In Exam - CBSE12D-2017 )

Rewrite the following C++ code after removing any/all syntactical errors wit

Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.

```void main()
{
cout<<"Enter an integer";
cin>>N;
switch(N%2)
case 0 cout<<"Even"; Break;
case 1 cout<<"Odd" ; Break;
}```

#### 01D #6012

( As In Exam - CBSE12D-2017 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

```#define Big(A,B) (A>B)?A+1:B+2
void main()
{
char W[] = "Exam";
int L=strlen(W);
for(int i =0; i<L-1; i++)
W[i] = Big(W[i],W[i+1]);
cout<<W<<endl;
}```

#### 01E #6016

( As In Exam - CBSE12D-2017 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program .

```void main()
{
int A[]={10,12,15,17,20,30};
for(int i = 0; i<6; i++)
{
if(A[i]%2==0)
A[i] /= 2;
else if(A[i]%3==0)
A[i] /= 3;
if(A[i]%5==0)
A[i] /= 5;
}
for(i = 0; i<6; i++)
cout<<A[i]<<"#";
}```

#### 01F #6018

( As In Exam - CBSE12D-2017 )

Look at the following C++ code and find the possible output(s) from the optio

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum values that can be assigned to each of the variables R and C.
Note:
– Assume all the required header files are already being included in the code.
– The function random(n) generates an integer between 0 and n-1

```void main()
{
randomize();
int R=random(3),C=random(4);
int MAT = {{10,20,30},{20,30,40},{30,40,50}};
for(int I=0; I<R; I++)
{
for(int J=0; J<C; J++)
cout<<MAT[I][J]<<" ";
cout<<endl;
}
}``` #### 02A #6022

( As In Exam - CBSE12D-2017 )

Differentiate between private and public members of a class in context of Obj

Differentiate between private and public members of a class in context of Object Oriented Programming. Also give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C++.

#### 02B #6025

( As In Exam - CBSE12D-2017 )

Observe the following C++ code and answer the questions (i) and (ii).
N

Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.

```class EXAM
{
long Code;
char EName;
float Marks;
public:
EXAM()           //Member Function 1
{
Code=100;strcpy(EName,"Noname");Marks=0;
}
EXAM(EXAM &E)    //Member Function 2
{
Code=E.Code+1;
strcpy(EName,E.EName);
Marks=E.Marks;
}
};
void main()
{
___________________     //Statement 1
___________________     //Statement 2
}```

(i) Which Object Oriented Programming feature is illustrated by the Member Function 1 and Member Function 2 together in the class EXAM?

(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.

#### 02C #6027

( As In Exam - CBSE12D-2017 )

```Write the definition of a class RING in C++ with following description:
Pr

```
```Write the definition of a class RING in C++ with following description:
Private Members
- RingNumber   // data member of integer type
- Radius       // data member of float type
- Area         // data member of float type
- CalcArea()   // Member function to calculate and assign
Public Members
- GetArea()    // A function to allow user to enter values of
// RingNumber and Radius. Also, this
// function should call CalcArea() to calculate
// Area
- ShowArea()   // A function to display RingNumber, Radius
// and Area```

#### 02D #6030

( As In Exam - CBSE12D-2017 )

Answer the questions (i) to (iv) based on the following:

```class One

```

Answer the questions (i) to (iv) based on the following:

```class One
{
int A1;
protected:
float A2;
public:
One();
void Get1(); void Show1();
};
class Two : private One
{
int B1;
protected:
float B2;
public:
Two();
void Get2();
void Show();
};
class Three : public Two
{
int C1;
public:
Three();
void Get3();
void Show();
};
void main()
{
Three T;     //Statement 1
__________________;  //Statement 2
}```

(i) Which type of Inheritance out of the following is illustrated in the above example?
-Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

(ii) Write the names of all the member functions, which are directly accessible by the object T of class Three as declared in main() function.

(iii) Write Statement 2 to call function Show() of class Two from the object T of class Three.

(iv) What will be the order of execution of the constructors, when the object T of class Three is declared inside main()?

#### 03A #6032

( As In Exam - CBSE12D-2017 )

Write the definition of a function Reverse(int Arr[], int N) in C++, which sh

Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array.
Example: if the array Arr contains

 13 10 15 20 5

Then the array should become

 5 20 15 10 13

NOTE:
-The function should only rearrange the content of the array.
-The function should not copy the reversed content in another array.
-The function should not display the content of the array.

#### Sum of middle row of 2D Matrix #6036

( As In Exam - CBSE12D-2017 )

Write definition for a function ADDMIDROW(int MAT[],int R,int C) in C++,�

Write definition for a function ADDMIDROW(int MAT[],int R,int C) in C++, which finds sum of the middle row elements of the matrix MAT (Assuming C represents number of Columns and R represents number of rows, which is an odd integer). For example, if the content of array MAT having R as 3 and C as 5 is as follows:

 1 2 3 4 5 2 1 3 4 5 3 4 1 2 5

The function should calculate the sum and display the following:
Sum of Middle Row: 15

#### 2-D Array Element Address Calculation #6039

( As In Exam - CBSE12D-2017 )

T is a two dimensional array, which is stored in the memory along the

T is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element T, if the element T is stored at the memory location 25000.

#### 03D #6041

( As In Exam - CBSE12D-2017 )

Write the definition of a member function ADDMEM() for a class QUEUE in C++,

Write the definition of a member function ADDMEM() for a class QUEUE in C++, to add a MEMBER in a dynamically allocated Queue of Members considering the following code is already written as a part of the program.

```struct Member
{
int MNO;
char MNAME;
Member *Next;
};
class QUEUE
{
Member *Rear,*Front;
public:
QUEUE(){Rear=NULL;Front=NULL;}
void REMOVEMEM();
~QUEUE();
};```

#### 03E #6043

( As In Exam - CBSE12D-2017 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
P + ( Q – R ) * S / T

#### 04A #6047

( As In Exam - CBSE12D-2017 )

Aditi has used a text editing software to type some text. After saving the ar

Aditi has used a text editing software to type some text. After saving the article as WORDS.TXT , she realised that she has wrongly typed alphabet J in place of alphabet I everywhere in the article.
Write a function definition for JTOI() in C++ that would display the corrected version of entire content of the file WORDS.TXT with all the alphabets “J” to be displayed as an alphabet “I” on screen .
Note: Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example: If Aditi has stored the following content in the file WORDS.TXT :

WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE

The function JTOI() should display the following content:

WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE

#### Counting of object containing a particular string match in a binary file #6049

( As In Exam - CBSE12D-2017 )

Write a definition for function COUNTDEPT( ) in C++ to read each object of a�

Write a definition for function COUNTDEPT( ) in C++ to read each object of a binary file TEACHERS.DAT, find and display the total number of teachers in the department MATHS. Assume that the file TEACHERS.DAT is created with the help of objects of class TEACHERS, which is defined below:

```class TEACHERS
{
int TID; char DEPT;
public:
void GET()
{
cin>>TID;gets(DEPT);
}
void SHOW()
{
cout<<TID<<":"<<DEPT<<endl;
}
char *RDEPT(){return DEPT;}
};```

#### 04C #6053

( As In Exam - CBSE12D-2017 )

Find the output of the following C++ code considering that the binary file B

Find the output of the following C++ code considering that the binary file BOOK.DAT exists on the hard disk with a data of 200 books.

```class BOOK
{
int BID;char BName;
public:
void Enter();void Display();
};
void main()
{
fstream InFile;
InFile.open("BOOK.DAT",ios::binary|ios::in);
BOOK B;
InFile.seekg(5*sizeof(B));
cout<<"Book Number:"<<InFile.tellg()/sizeof(B) + 1;
InFile.seekg(0,ios::end);
cout<<" of "<<InFile.tellg()/sizeof(B)<<endl;
InFile.close();
}```

#### 01A-2016 #6074

( As In Exam - CBSE12D-2016 )

Out of the following, find those identifiers, which cannot be used for naming

Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a C++ program:

_Cost, Price*Qty, float, Switch,

#### 01B-2016 #6077

( As In Exam - CBSE12D-2016 )

Jayapriya has started learning C++ and has typed the following program. When

Jayapriya has started learning C++ and has typed the following program. When she compiled the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

```void main()
{
float A,Number,Outcome;
cin>>A>>Number;
Outcome=pow(A,Number);
cout<<Outcome<<endl;
}```

#### 01C-2016 #6079

( As In Exam - CBSE12D-2016 )

Rewrite the following C++ code after removing any/all syntactical errors with

Rewrite the following C++ code after removing any/all syntactical errors with
each correction underlined.
Note: Assume all required header files are already being included in the program.

```#define Equation(p,q) = p+2*q
void main()
{
float A=3.2;B=4.1;
C=Equation(A,B);
cout<<'Output='<<C<<endl;
}```

#### 01D-2017 #6083

( As In Exam - CBSE12D-2016 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

```typedef char STRING;
void MIXITNOW(STRING S)
{
int Size=strlen(S);
for (int I=0;I<Size-1;I+=2)
{
char WS=S[I];
S[I]=S[I+1];
S[I+1]=WS;
}
for (I=1;I<Size;I+=2)
if (S[I]>='M' && S[I]<='U')
S[I]=’@’;
}
void main()
{
STRING Word="CRACKAJACK";
MIXITNOW(Word);
cout<<Word<<endl;
}```

#### 01E-2016 #6085

( As In Exam - CBSE12D-2016 )

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```class Stock
{
long int ID;
float Rate; int Date;
public:
Stock(){ID=1001;Rate=200;Date=1;}
void RegCode(long int I,float R)
{
ID=I; Rate=R;
}
void Change(int New,int DT)
{
Rate+=New; Date=DT;
}
void Show()
{
cout<<”Date :”<<Date<<endl;
cout<<ID<<”#”<<Rate<<endl;
}
};
void main()
{
Stock A,B,C;
A.RegCode(1024,150);
B.RegCode(2015,300);
B.Change(100,29);
C.Change(20,20);
A.Show();
B.Show();
C.Show();
}```

#### 01F-2016 #6146

( As In Exam - CBSE12D-2016 )

Look at the following C++ code and find the possible output(s) from the optio

Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable CHANGER.
Note:
– Assume all the required header files are already being included in the code.
– The function random(n) generates an integer between 0 and n-1

```void main()
{
randomize();
int CHANGER;
CHANGER=random(3);
char CITY[]={”DELHI”,”MUMBAI”,”KOLKATA” ,”CHENNAI”};
for(int I=0;I<=CHANGER;I++)
{
for(int J=0;J<=I;J++)
cout<<CITY[J];
cout<<endl;
}
}```
(i) (ii)
DELHI

DELHIMUMABAI

DELHIMUMABAIKOLKATA

DELHI

DELHIMUMABAI

DELHIMUMABAIKOLKATA

DELHIMUMABAIKOLKATACHENNAI

(iii) (iv)
MUMABAI

MUMABAIKOLKATA

MUMABAIKOLKATACHENNAI

KOLKATA

KOLKATACHENNAI

#### 02A-2016 #6154

( As In Exam - CBSE12D-2016 )

Differentiate between Constructor and Destructor functions giving suitable ex

Differentiate between Constructor and Destructor functions giving suitable example using a class in C++. When does each of them execute?

#### 02B-2016 #6158

( As In Exam - CBSE12D-2016 )

Observe the following C++ code and answer the questions (i) and (ii). Assume

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included:

```class FICTION
{
long FCode;
char FTitle;
float FPrice;
public:
FICTION() //Member Function 1
{
cout<<”Bought”<<endl;
FCode=100;strcpy(FTitle,”Noname”);FPrice=50;
}
FICTION(int C,char T[],float P) //Member Function 2
{
FCode=C;
strcpy(FTitle,T);
FPrice=P;
}
void Increase(float P) //Member Function 3
{
FPrice+=P;
}
void Show()           //Member Function 4
{
cout<<FCode<<”:”<<FTitle<<”:”<<FPrice<<endl;
}
~FICTION()            //Member Function 5
{
cout<<”Fiction removed!”<<end1;
}
};
void main()                          //Line 1
{                                    //Line 2
FICTION F1,F2(101,”Dare”,75);      //Line 3
for (int I=0;I<4;I++)              //Line 4
{                                  //Line 5
F1.Increase(20);F2.Increase(15); //Line 6
F1.Show();F2.Show();             //Line 7
}                                  //Line 8
}                                    //Line 9```

(i) Which specific concept of object oriented programming out of the following is illustrated by Member Function 1 and Member Function 2 combined together?
– Data Encapsulation
– Data Hiding
- Polymorphism
– Inheritance

(ii) How many times the message ”Fiction removed!” will be displayed after executing the above C++ code? Out of Line 1 to Line 9, which line is responsible to display the message “Fiction removed!”?

#### 02C-2016 #6160

( As In Exam - CBSE12D-2016 )

```Write the definition of a class METROPOLIS in C++ with following descriptio

```
```Write the definition of a class METROPOLIS in C++ with following description:
Private Members
-Mcode    //Data member for Code (an integer)
-MName    //Data member for Name (a string)
-MPop     //Data member for Population (a long int)
-Area     //Data member for Area Coverage (a float)
-PopDens  //Data member for Population Density (a float)
-CalDen() //A member function to calculate
//Density as PopDens/Area
Public Members
-Enter()  //A function to allow user to enter values of
//Mcode,MName,MPop,Area and call CalDen()
//function
-ViewALL()//A function to display all the data members
//also display a message "Highly Populated Area"
//if the Density is more than 12000```

#### 02D-2016 #6162

( As In Exam - CBSE12D-2016 )

Answer the questions (i) to (iv) based on the following:

```class PRODU

```

Answer the questions (i) to (iv) based on the following:

```class PRODUCT
{
int Code;
char Item;
protected:
float Qty;
public:
PRODUCT();
void GetIn(); void Show();
};
class WHOLESALER
{
int WCode;
protected:
char Manager;
public:
WHOLESALER();
void Enter();
void Display();
};
class SHOWROOM : public PRODUCT, private WHOLESALER
{
char Name,City;
public:
SHOWROOM();
void Input();
void View();
};```

(i) Which type of Inheritance out of the following is illustrated in the above example?
– Single Level Inheritance
– Multi Level Inheritance
– Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the
member functions of class SHOWROOM.
(iii) Write the names of all the member functions, which are directly accessible by an
object of class SHOWROOM.
(iv) What will be the order of execution of the constructors, when an object of class
SHOWROOM is declared?

#### Value modification function of 1 D array using slab based conditions #6165

( As In Exam - CBSE12D-2016 )

Write the definition of a function FixPay(float Pay[], int N) in C++, which s

Write the definition of a function FixPay(float Pay[], int N) in C++, which should
modify each element of the array Pay having N elements, as per the following
rules:

Existing Value of Pay Pay to be changed to
If less than 100000 Add 25% in the existing value
If >=100000 and <20000 Add 20% in the existing value
If >=200000 Add 15% in the existing value

#### Finding relative address in 2D Array #6167

( As In Exam - CBSE12D-2016 )

T is a two dimensional array, which is stored in the memory along the

T is a two dimensional array, which is stored in the memory along the row with each of its element occupying 4 bytes, find the address of the element T, if the element T is stored at the memory location 52000.

#### 03C-2016 #6170

( As In Exam - CBSE12D-2016 )

Write the definition of a member function INSERT() for a class QUEUE in C++,

Write the definition of a member function INSERT() for a class QUEUE in C++, to insert an ITEM in a dynamically allocated Queue of items considering the following code is already written as a part of the program.

```struct ITEM
{
int INO; char INAME;
};
class QUEUE
{
ITEM *R,*F;
public:
QUEUE(){R=NULL;F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};```

#### Function to show middle row and middle column of a 2D Array #6174

( As In Exam - CBSE12D-2016 )

Write definition for a function SHOWMID(int P[],int R,int C) in C++ to dis

Write definition for a function SHOWMID(int P[],int R,int C) in C++ to display the elements of middle row and middle column from a two dimensional array P having R number of rows and C number of columns.
For example, if the content of array is as follows:

 115 112 116 101 125 103 101 121 102 101 185 109 109 160 172

The function should display the following as output :
103 101 121 102 101
116 121 109

#### 03E-2016 #6177

( As In Exam - CBSE12D-2016 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
A/(B+C)*D-E

#### Finding 4 character words in a text file #6179

( As In Exam - CBSE12D-2016 )

Write function definition for WORD4CHAR() in C++ to read the content of a tex

Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TXT, and display all those words, which has four characters in it.
Example: If the content of the file fun.TXT is as follows:

 When I was a small child, I used to play in the garden with my grand mom. Those days were amazingly funful and I remember all the moments of that time

The function WORD4CHAR() should display the following:

 When used play with days were that time

#### Finding data match in binary file #6182

( As In Exam - CBSE12D-2016 )

Write a definition for function BUMPER( ) in C++ to read each object of a bin

Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFTS.DAT, find and display details of those gifts, which has remarks as “ÖN DISCOUNT”. Assume that the file GIFTS.DAT is created with the help of objects of class GIFTS, which is defined below:

```class GIFTS
{
public:
void Takeonstock()
{
}
void See()
{
}
char *GetRemarks(){return Remarks;}
};```

#### Finding position in binary file using tellg() #6184

( As In Exam - CBSE12D-2016 )

Find the output of the following C++ code considering that the binary file ME

Find the output of the following C++ code considering that the binary file MEM.DAT exists on the hard disk with a data of 1000 members.

```class MEMBER
{
int Mcode;char MName;
public:
void Register();void Display();
};
void main()
{
fstream MFile;
MFile.open("MEM.DAT",ios::binary|ios::in);
MEMBER M;
cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl;
cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl;
MFile.close();
}```

#### 01A-2019S #6559

( As In Exam - CBSE12S-2019 )

Write the type of C++ Operators (Arithmetic, Logical, and Relational Operator

Write the type of C++ Operators (Arithmetic, Logical, and Relational Operators) from the following:
(i) !(ii) !=(iii) &&(iv) %

#### 01B-2019S #6562

( As In Exam - CBSE12S-2019 )

Observe the following program very carefully and write the name of those head

Observe the following program very carefully and write the name of those header file(s), which are essentially needed to compile and execute thefollowing program successfully:

```void main()
{
char text, newText;
gets(text);
strcpy(newText,text);
for(int i=0;i<strlen(text);i++)
if(text[i]==’A’)
text[i]=text[i]+2;
puts(text);
}```

#### 01C-2019S #6564

( As In Exam - CBSE12S-2019 )

Rewrite the following C++ code after removing any/all Syntactical Error(s) wi

Rewrite the following C++ code after removing any/all Syntactical Error(s) with each correction underlined.
Note: Assume all required header files are already being included in the program.

```#define float PI 3.14
void main( )
{
float R=4.5,H=1.5;
A=2*PI*R*H + 2*PIpow(R,2);
cout<<'Area='<<A<<endl;
}```

#### 01D-2019S #6567

( As In Exam - CBSE12S-2019 )

Find and write the output of the following C++ program code: Note: Assume all

Find and write the output of the following C++ program code: Note: Assume all required header files are already being included in the program.

```void main( )
{
int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
int *Ptr = Ar , I ;
cout<<++*Ptr++ << '@' ;
I = Ar - Ar ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ; for( ; I >=0 ; I -=2)
cout<<Ar[I] << '@' ;
}```

#### 01E-2019S #6570

( As In Exam - CBSE12S-2019 )

Find and write the output of the following C++ program code:

```typedef

```

Find and write the output of the following C++ program code:

```typedef char STRING;
void MIXNOW(STRING S)
{
int Size=strlen(S);
for(int I=0;I<Size;I+=2)
{
char WS=S[I];
S[I]=S[I+1];
S[I+1]=WS;
}
for (I=1;I<Size;I+=2)
if (S[I]>='M' && S[I]<='U')
S[I]='@';
}
void main()
{
STRING Word="CBSEEXAM2019";
MIXNOW(Word);
cout<<Word<<endl;
}```

#### 01F-2019S #6572

( As In Exam - CBSE12S-2019 )

Observe the following program and find out, which output(s) out of (i) to (iv

Observe the following program and find out, which output(s) out of (i) to (iv) willbe expected from the program? What will be the minimum and the maximum value assigned to the variable Alter?
Note: Assume all required header files are already being included in the program.

```void main( )
{
randomize();
int Ar[]={10,7}, N;
int Alter=random(2) + 10 ;
for (int C=0;C<2;C++)
{
N=random(2) ;
cout<<Ar[N] +Alter<<"#";
}
}
(i) 21#20#     (ii) 20#18#
(iii) 20#17#   (iv) 21#17#```

#### 02A-2019S #6580

( As In Exam - CBSE12S-2019 )

What is a copy constructor? Illustrate with a suitable C++ example.

What is a copy constructor? Illustrate with a suitable C++ example.

#### 02B-2019S #6583

( As In Exam - CBSE12S-2019 )

Write the output of the following C++ code. Also, write the name of feature o

Write the output of the following C++ code. Also, write the name of feature of Object Oriented Programming used in the following program jointly illustrated by the Function 1 to Function 4.

```void My_fun ( )             // Function 1
{
for (int I=1 ; I<=50 ; I++) cout<< "-" ;
cout<<end1 ;
}
void My_fun (int N)         // Function 2
{
for (int I=1 ; I<=N ; I++) cout<<"*" ;
cout<<end1 ;
}
void My_fun (int A, int B)   // Function 3
{
for (int I=1. ;I<=B ;I++) cout <<A*I ;
cout<<end1 ;
}
void My_fun (char T, int N)   // Function 4
{
for (int I=1 ; I<=N ; I++) cout<<T ;
cout<<end1;
}
void main ( )
{
int X=7, Y=4, Z=3;
char C='#' ;
My_fun (C,Y) ;
My_fun (X,Z) ;
}```

OR

Write any four differences between Constructor and Destructor function with respect to object oriented programming

#### 02C-2019S #6589

( As In Exam - CBSE12S-2019 )

Define a class Ele_Bill in C++ with the following descriptions:

```

```

Define a class Ele_Bill in C++ with the following descriptions:

```Private members:
Cname           of type character array
Pnumber         of type long
No_of_units     of type integer
Amount          of type float.
Calc_Amount( )  This member function should calculate the
amount asNo_of_units*Cost .```

Amount can be calculated accordingto the following conditions:

```No_of_units Cost
First 50 units     Free
Next 100 units     0.80 @ unit
Next 200 units     1.00 @ unit
Remaining units    1.20 @ unit
Public members:
* A function Accept( ) which allows user to enter Cname,
Pnumber, No_of_units and invoke function Calc_Amount().
* A function Display( ) to display the values of all the data members
on the screen.```

#### 02D-2019S #6591

( As In Exam - CBSE12S-2019 )

Answer the questions (i) to (iv) based on the following:

```class Facul

```

Answer the questions (i) to (iv) based on the following:

```class Faculty
{
int FCode;
protected:
char FName;
public:
Faculty();
void Enter();
void Show();
};
class Programme
{
int PID;
protected:
char Title;
public:
Programme();
void Commence();
void View();
};
class Schedule: public Programme, Faculty
{
int DD,MM,YYYY;
public:
Schedule();
void Start();
void View();
};
void main()
{
Schedule S; //Statement 1
___________ //Statement 2
}```

OR

Consider the following class State :

```  class State
{
protected :
int tp;
public :
State( ) { tp=0;}
void inctp( ) { tp++;};
int gettp(); { return tp; }
};```

Write a code in C++ to publically derive another class ‘District’ with the following additional members derived in the public visibility mode.
Data Members :
Dname string
Distance float
Population long int
Member functions :
DINPUT( ) : To enter Dname, Distance and population
DOUTPUT( ) : To display the data members on the screen.

(i) Write the names of all the member functions, which are directly accessible by the object S of class Schedule as declared in main() function.

(ii) Write the names of all the members, which are directly accessible by the memberfunction Start( ) of class Schedule.

(iii) Write Statement 2 to call function View( ) of class Programme from the object S of class Schedule.

(iv) What will be the order of execution of the constructors, when the object S of class Schedule is declared inside main()?

#### 03A-2019S #6595

( As In Exam - CBSE12S-2019 )

Write a user-defined function AddEnd4(int A[],int R,int C) in C++ to find

Write a user-defined function AddEnd4(int A[],int R,int C) in C++ to find and display the sum of all the values, which are ending with 4 (i.e., unit place is 4).
For example if the content of array is:

 24 16 14 19 5 4

The output should be 42

OR

Write a user defined function in C++ to find the sum of both left and right diagonal elements from a two dimensional array.

#### 03B-2019S #6598

( As In Exam - CBSE12S-2019 )

Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ to

Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ to find and display the extra element in Array A. Array A contains all the elements of array B but one more element extra. (Restriction: array elements are not in order)
Example : If the elements of Array A is 14, 21, 5, 19, 8, 4, 23, 11
and the elements of Array B is 23, 8, 19, 4, 14, 11, 5
Then output will be 21

OR

Write a user defined function Reverse(int A[],int n) which accepts an integer array and its size as arguments(parameters) and reverse the array.
Example : if the array is 10,20,30,40,50 then reversed array is 50,40,30,20,10

#### 03C-2019S #6601

( As In Exam - CBSE12S-2019 )

An array S  is stored in the memory along the column with each of its

An array S  is stored in the memory along the column with each of its element occupying 2 bytes. Find out the memory location of S, if element S is stored at the location 8200.

OR

An array A is stored in the memory with each element requiring 4 bytes of storage ,if the base address of A is 4500 ,Find out memory locations of A, if the content is stored along the row.

#### 03D-2019S #6604

( As In Exam - CBSE12S-2019 )

Write the definition of a member function Ins_Player() for a class CQUEUE in

Write the definition of a member function Ins_Player() for a class CQUEUE in C++, to add a Player in a statically allocated circular queue of PLAYERs considering the following code is already written as a part of the program:

```struct Player
{
long Pid;
char Pname;
};
const int size=10;
class CQUEUE
{
Player Ar[size];
int Front, Rear;
public:
CQUEUE( )
{
Front = -1;
Rear=-1;
}
void Ins_Player(); // To add player in a static circular queue
void Del_Player(); // To remove player from a static circular queue
void Show_Player(); // To display static circular queue
};```

#### 03E-2019S #6607

( As In Exam - CBSE12S-2019 )

Convert the following Infix expression to its equivalent Postfix expression,

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
A/B+C*(D-E)

OR

Evaluate the following Postfix expression :
4,10,5,+,*,15,3,/,-

#### 04A-2019S #6610

( As In Exam - CBSE12S-2019 )

Write a function RevText() to read a text file “ Input.txt “ and Print on

Write a function RevText() to read a text file “ Input.txt “ and Print only word starting with ‘I’ in reverse order .
Example: If value in text file is: INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY

OR

Write a function in C++ to count the number of lowercase alphabets present in a text file “BOOK..txt”.

#### 04B-2019S #6612

( As In Exam - CBSE12S-2019 )

Write a function in C++ to search and display details, whose destination is

Write a function in C++ to search and display details, whose destination is
“Cochin” from binary file “Bus.Dat”. Assuming the binary file is containing the objects of the following class:

```class BUS
{
int Bno; // Bus Number
char From; // Bus Starting Point
char To; // Bus Destination
public:
char * StartFrom ( ); { return From; }
void input() { cin>>Bno>>; gets(From); get(To); }
void show( ) { cout<<Bno<< ":"<<From << ":"<<To<<endl; }
};```

OR

Write a function in C++ to add more new objects at the bottom of a binary file “STUDENT.dat”, assuming the binary file is containing the objects of the following class :

```class STU
{
int Rno;
char Sname;
public: void Enter()
{
cin>>Rno;gets(Sname);
}
void show()
{
count << Rno<<sname<<endl;
}
};```

#### 04C-2019S #6615

( As In Exam - CBSE12S-2019 )

Find the output of the following C++ code considering that the binary file P

Find the output of the following C++ code considering that the binary file PRODUCT.DAT exists on the hard disk with a list of data of 500 products.

```class PRODUCT
{
int PCode;char PName;
public:
void Entry();void Disp();
};
void main()
{
fstream In;
In.open("PRODUCT.DAT",ios::binary|ios::in);
PRODUCT P;
In.seekg(0,ios::end);
cout<<"Total Count: "<<In.tellg()/sizeof(P)<<endl;
In.seekg(70*sizeof(P));
cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
In.close();
}```

OR

Which file stream is required for seekg() ?

#### 01A-2018S #6637

( As In Exam - CBSE12S-2018 )

What is the role of a parameter/argument passed in a function? Can a default

What is the role of a parameter/argument passed in a function? Can a default value be assigned to a parameter(Yes/No)? If yes, justify your answer with the help of a suitable example otherwise give reason.

#### 01B-2018S #6641

( As In Exam - CBSE12S-2018 )

Raman suggests Kishan the following header files which are required to be inc

Raman suggests Kishan the following header files which are required to be included in the given C++ program. Identify the header files which are wrongly suggested by Raman.

Program:

```void main()
{
}```

1. iostream.h
2. stdio.h
3. conio.h
4. ctype.h

#### 01C-2018S #6644

( As In Exam - CBSE12S-2018 )

Rewrite the following program after removing the syntactical errors (if any).

Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

```#include<iostream.h>
#include<conio.h>
Typedef int Num;
Num full=100;
Num Calc(int X)
{
full=(X>2)?1:2;
return (full%2)
}
void main
{
int full = 1000;
full =Calc(::full);
cout<<::full<<"::">>full>>endl;
}

```

#### 01D-2018S #6646

( As In Exam - CBSE12S-2018 )

Write the output of the following C++ program code (assume all necessary head

Write the output of the following C++ program code (assume all necessary header files are included in program) :

```void Encrypt(char *S, int key)
{
char *Temp=S;
if(key%2==0)
{ key--; }
while (*Temp!='\0')
{
*Temp+=key;
Temp+= key;
}
}
void main()
{
int Key_Set[]={1,2,3};
char Pvt_Msg[]="Computer2017";
for(int C=0; C<2; C++)
{
Encrypt(Pvt_Msg, Key_Set[C]);
cout<<"New Encrypted Message after Pass "<<C+1<<" is : "<<Pvt_Msg;
cout<<endl;
}
}```

#### 01E-2018S #6649

( As In Exam - CBSE12S-2018 )

Write the output of the following C++ program code(assume all necessary heade

Write the output of the following C++ program code(assume all necessary header files are included in program):

struct Ticket
{
char Level;
int Price;
};
void Compute(Ticket &T)
{
if (T.Level==’A’)
T.Price+=50;
else if (T.Level==’B’)
T.Price+=30;
else if (T.Level==’C’)
T.Price+=25;
cout<=0;)
{
Compute(Mon_Show[count–]);
}
}

#### 01F-2018S #6652

( As In Exam - CBSE12S-2018 )

Consider the following C++ program code and choose the option(s) which are no

Consider the following C++ program code and choose the option(s) which are not possible as output. Also, print the minimum & maximum value of variable Pick during complete execution of the program.(assume all necessary header files are included in program):

```const int NUM=5;
void main()
{
randomize();
int V1=1, V2=5, Pick;
while(V1<V2)
{
Pick = random(NUM) + (V2-V1);
cout<<Pick<<":";
V1++;
}
}```

(a) 5:6:6:6:
(b) 4:7:5:3:
(c) 8:6:1:2:
(d) 7:5:3:1

#### 02A-2018S #6654

( As In Exam - CBSE12S-2018 )

What do you mean by Data Abstraction in OOPs? Explain its significance with a

What do you mean by Data Abstraction in OOPs? Explain its significance with a suitable example.

#### 02B-2018S #6657

( As In Exam - CBSE12S-2018 )

Answer the question (i) & (ii) after going through the following code. (a

Answer the question (i) & (ii) after going through the following code. (assume all necessary header files are included in program):-

```class Game
{
char Name ;
int No_of_Players;
public:
Game()          //Function 1
{
strcpy(Name, "Cricket");
No_of_Players=11;
cout<<"New Game Starts\n";
}
Game(char N[], int No) //Function 2
{
strcpy(Name, N);
No_of_Players=No;
cout<<Name<<"comprises"<<No_of_Players<<"number of players\n";
}
~Game()   //Function 3
{
cout<<"Game Ends\n";
}
};```

(i) Give the name of the feature of OOP which is implemented by Function 1 & 2 together in the above class Game.
(ii) Anuj made changes to the above class Game and made Function 3 private. Will he be able to execute the Line 1 successfully given below? Justify.
void main()
{
Game ABC; //Line 1
}

#### 02C-2018S #6661

( As In Exam - CBSE12S-2018 )

Define a class Bill in OOP with the following specification:-
Private m

Define a class Bill in OOP with the following specification:-
Private members:
1. Bill_no – type long(bill number)
2. Bill_period – type integer(number of months)
3. No_of_calls – type integer(number of mobile calls)
4. Payment_mode – type string(“online” or “offline”)
5. Amount – type float(amount of bill)
6. Calculate_Bill() function to calculate the amount of bill given as per the following conditions:

No_of_calls Calculation Rate/call
(in rupees)
<=500 1.0
501-1200 2.0
>1200 4.0

Also, the value of Amount should be reduced by 5% if Payment_mode is “online”.
Public members:
1. A member function New_Bill() that will accept the values for Bill_no, Bill_period, No_of_calls, Payment_mode from the user and invoke Caluclate_Bill() to assign the value of Amount.
2. A member function Print_Bill() that will display all details of a Bill.

#### 02D-2018S #6664

( As In Exam - CBSE12S-2018 )

```Answer the question from (i) to (iv) based on the given below code
(assume

```
```Answer the question from (i) to (iv) based on the given below code
(assume all necessary header files are included in program):-

class City
{
int City_Id;
char City_Name;
protected:
int City_Population;
public:
City();
void Get_Population();
void New_City();
void Show_City;
};
class State : public City
{
int State_Id;
char State_Name;
protected:
int State_Population;
public:
State();
void New_State();
void Print_State();
};
class Country : private State
{
int Country_Id;
char Country_Name;
public;
Country();
void New_Country();
void Display_Country();
};```

(i) Write name of the class whose constructor is invoked first on the creation of a new object of class Country.
(ii) Write name of the data members which are accessible through the object of class Country.
(iii) List name of the members which are accessible through the member function “void New_Country()”.
(iv) What will be the size(in bytes) of an object of class Country & State respectively.

#### 03A-2018S #6667

( As In Exam - CBSE12S-2018 )

Write the definition of function named Array_Swap() that will accept an integ

Write the definition of function named Array_Swap() that will accept an integer array & its size as arguments and the function will interchange/swap elements in such a way that the first element is swapped with the last element, second element is swapped with the second last element and so on, only if anyone or both the elements are odd.
E.g. if initially array of seven elements is:
5, 16, 4, 7, 19, 8, 2
After execution of the above function, the contents of the array will be:
2,16, 19, 7, 4, 8, 5

#### 03B-2018S #6669

( As In Exam - CBSE12S-2018 )

An array A is stored along the row in the memory with each element re

An array A is stored along the row in the memory with each element requiring 4 bytes of storage. If the element A is stored at 21500, then find out the base address of the array and the memory address of element stored at location A?

#### 03C-2018S #6671

( As In Exam - CBSE12S-2018 )

Write the definition of a member function Q_Insert() for a class Exam_Queue i

Write the definition of a member function Q_Insert() for a class Exam_Queue in C++ to insert a new Application information in a dynamically allocated queue whose code is already given below as a part of the program(assume all necessary header files are included in program):

```struct Application
{
int App_Id;
char App_Name;
};
class Exam_Queue
{
Application *Front, *Rear;
public;
Exam_Queue()   //Constructor
{
Front=Rear=NULL;
}
void Q_Insert ();
void Q_Delete();
};

```

#### 03D-2018S #6675

( As In Exam - CBSE12S-2018 )

Write the definition of a user-defined function REPEAT_ROW(int A[],int R,

Write the definition of a user-defined function REPEAT_ROW(int A[],int R, int C) in C++ that will store the elements in the following manner
1. All row elements except the 1st element replaced by the 1st element,
2. All row elements except the 1st & 2nd element replaced by the 2nd element,
3. All row elements except the 1st , 2nd & 3rd element replaced by the 3rd element and so on.
For example: if initially the array was:-

2 6 9 12 5 6 10 2 18 14 5 6

Then, the contents of the array after execution of the above function will be:-

2 6 6 6 5 5 5 5 18 14 5 5

#### 03E-2018S #6691

( As In Exam - CBSE12S-2018 )

Evaluate the following POSTFIX expression. Show the status of Stack after exe

Evaluate the following POSTFIX expression. Show the status of Stack after execution of each operation separately:
TRUE, FALSE, OR, NOT, TRUE, FALSE, AND, OR

#### 04A-2018S #6694

( As In Exam - CBSE12S-2018 )

Answer the questions (i) & (ii) in the program segment given below for th

Answer the questions (i) & (ii) in the program segment given below for the required task.

```class Route
{
int Route_No;        //Route Number
char Route_name; //Name of Route
int No_Kms;          // Distance in kms on Route
public;
void New_Route();    // Accepts details of new Route
void Show_Route();   // Display details of a Route
int Get_RouteNo();   //Return the Route Number
{  return Route_No;  }
void Update_Kms(int K)
{ No_Kms=K;}
};
void Update_Route(int No, int New_Kms) //Update No_Kms of a Route
{
Route R;
fstream File("ROUTE.DAT" , ios::in | ios::out | ios::binary);
while(!File.eof())
{
if(( R.Get_RouteNo()==No))
{ R.update_Kms(New_Kms);
___________________   //Statement 1
___________________   //Statement 2
cout<<"Route Details updated\n";
}
}
File.close();
}

```

(i) Write Statement 1 to position the file pointer to the appropriate place so that the data updation is done for the correct Route.
(ii) Write Statement 2 to perform the write operation so that the updation is done in the binary file “ROUTE.DAT”.

#### 04B-2018S #6696

( As In Exam - CBSE12S-2018 )

Write a user-defined function named Count() that will read t

Write a user-defined function named Count() that will read the contents of text file named “Report.txt” and display the count of the number of lines that start with either „I. or „M..
E.g. In the following paragraph, there are 3 lines starting with „I. or „M.:
“India is the fastest growing economy.
India is looking for more investments around the globe.
The whole world is looking at India as a great market.
Most of the Indians can foresee the heights that India is capable of reaching.”

#### 04C-2018S #6698

( As In Exam - CBSE12S-2018 )

Consider the following class Item:-

```class Item
{
int ItemId;

```

Consider the following class Item:-

```class Item
{
int ItemId;
int Quantity;
float Price;
public:
void NewItem()
{
cin>>ItemId>>Quantity>>Price;
}
void ShowItem()
{
cout<<ItemId<<":"<<Quantity<<":"<<Price<<endl;
}
void Set_Price(float P)
{ Price=P;
int Ret_Id()
{ return ItemId; }
};```

Write a function named Change_Item(int Id, float Pr) to modify the price of the item whose Itemid & new price are passed as an argument.

#### 01A-2019S #6942

( As In Exam - CBSE12A-2019 )

Write the names of any four fundamental data types of C++

Write the names of any four fundamental data types of C++

#### 01B-2019S #6944

( As In Exam - CBSE12A-2019 )

Write the names of the correct header files, which must be included in the fo

Write the names of the correct header files, which must be included in the following C++ code to compile the code successfully:

```void main ()
{
char L[]="CS 2018";
int N=strlen(L);
cout<<L[N-1];
}```

#### 01C-2019S #6951

( As In Exam - CBSE12A-2019 )

Rewrite the following C++ Program after removing any/all syntactical error(s)

Rewrite the following C++ Program after removing any/all syntactical error(s). Underline each correction done in the code:

Note: Assume all required header files are already included in the profram.

```#define Area(L,B) = L*B
structure Recta
{
};
void main()
{
Recta R= [10, 15];
}```

#### Function arguments as pointer reference – Output writing #6953

( As In Exam - CBSE12A-2019 )

Find and write the output of the following C++ program code:

Note: Ass

Find and write the output of the following C++ program code:

Note: Assume all required header files are already included in the program.

```void Alter(char *S1, char *S2)
{
char *T;
T=S1;
S1=S2;
S2=T;
cout<<S1<<"&"<<S2<<endl;
}
void main()
{
charX[]="First", Y[]="Second";
Alter(X,Y);
cout<<X<<"*"<<Y<<endl;
}```

#### 01E-2019S #6959

( As In Exam - CBSE12A-2019 )

Find and write the output of the following C++ program code:

Note: Ass

Find and write the output of the following C++ program code:

Note: Assume all required header files are already included in the program.

```void Convert(float &X, int Y=2)
{
X=X.Y;
Y=X+Y;
cout<<X<<"*"<<Y<<endl;
}
void main()
{
float M=15, N=5;
Convert(M,N) ;
Convert(N) ;
Convert(M) ;
}```

#### 01F-2019S #6962

( As In Exam - CBSE12A-2019 )

Observe the following C++ code and find the possible output(s) from

th

Observe the following C++ code and find the possible output(s) from

the option (i) to (iv) following it Also, write the minimum and maximum values that can possibly be assigned to the variable End.

Note:

-Assume all the required header files are already  being included in the code.

-The function random(N) generated any possible integer between 0 amd M-1 (both values included)

```void main()
{
randomize();
int a[] = {10,10,30,40,50,60,70,80};
int Start = random(2) +1;
int End = Start + random(4);
for (int I-Start; I<=End, I++)
cout<<A[I]<<"\$";
}```
 (1) 10\$20\$30\$ (ii) 20\$30\$40\$50\$60\$ (iii) 30\$40\$50\$60\$ (iv) 40\$50\$60\$70\$

#### 02A-2019S #6968

( As In Exam - CBSE12A-2019 )

Given the following class Test and assuming all necessary header file(s) incl

Given the following class Test and assuming all necessary header file(s) included, answer the questions that follow the code:

```class Test
{
int Marks; char TName;
public;
Test(int M)    //Function 1
{
Marks = M;
}
Test(char S[])   //Function 2
{
strocpy(TName, S);
}
Test(char S[], int M)  //Function 3
{
Marks = M;
strcpy(TName, S);
}
Test(Test &T) //Function 4
{
Marks = T.Marks+10;
strcpy(TName, T.TName);
}
};

void main()
{
Test T1 (10); //Statement I
Test T2 (70); //Statement II
Test T3 (30, "PEACTICAL"); //Statement
}```

(i) Which of the Statement(S) out of (I), (II), (III), (IV) is/are incorrect for object(s) of the class Test?

(ii) What is Function 4 known as ? Write the Statement IV, that would execute Function 4.

#### 02B-2019S-C1 #6970

( As In Exam - CBSE12A-2019 )

Observe the following C++ code and answer the questions (i) and (ii).

Observe the following C++ code and answer the questions (i) and (ii).

Note: Assume all necessary files are included.

```class Point
{
int X,Y;
public:
Point(int I=10, int J=20) //Function 1
{
X=J;
Y=I;
}
void Show()      //Function 2
{
cout<<"Points are"<<X<<"&"<<Y<<endl;
}
~Point()    //Function 3
{
cout<<"Points Erased"<<endl;
}
};
void main()
{
Point P(5);
P.Show();
}

```

(i) For the class Point, what is Function 3 known as ? When is it executed ?

(ii) What is the output of the above code, on execution ?

#### 02B-2019S-C2 #6972

( As In Exam - CBSE12A-2019 )

Explain Polymorphism in context of Object Oriented Programming.

Also g

Explain Polymorphism in context of Object Oriented Programming.

Also give a supporting example in C++.

#### 02C-2019S #6977

( As In Exam - CBSE12A-2019 )

Write the definition of a class GRAPH in C++ with following description:

Write the definition of a class GRAPH in C++ with following description:

Private Members
– XUnit // integer
– YUnit // integer
– Type // char array of size 20
– AssignType() /* Member function to assign value of Type based upon XUnit and YUnit as follows: */

 Condition Type XUnit = 0 or YUnit = 0 None XUnit is more than YUnit Bar XUnit is less than or equal to YUnit Line

Public Members

• InXY( ) /* Function to allow user to enter values of XUnit and YUnit and hen invoke AssignType() to assign value of Type*/
• OutXY()   //Function to ddisplay XUnit, Yunit and Type

#### 02D-2019S-C1 #6982

( As In Exam - CBSE12A-2019 )

Answer the questions (i) to (iv) based on the following:

```class Groun

```

Answer the questions (i) to (iv) based on the following:

```class Ground
{
int Rooms;
protected:
void Put();
public:
void Get();
};

class Middle : private Ground
{
int Labs;
public:
void Tak();
void Give();
};

class Top : public Middle
{
int Roof;
public:
void In();
void Out();
};
void main()
{
Top T;
}```

(i) Which type of Inheritance out of the following is illustrated in the above example ?

– Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

(ii) Write the names of all the members, which are directly accessible by the member function Give() of class Middle.

(iii) write the names of all the members, which are directly accessible by the member function Out() of class Top.

(iv) Write the names of all the members, which are directly accessible by the object T of class Top declared in the main() function.

#### 02D-2019S-C2 #6985

( As In Exam - CBSE12A-2019 )

```class HeadQuarter
{
int

```

```class HeadQuarter
{
int Code;
char Des;
protected:
public:
};
```

Write a code in C++ to protectedly derive another class FrontOffice From the base class HeadQuarter with following members.

Data Members

Location of type character of size 10

Budget of type double

Member Functions

A constructor function to assign budget as 100000

Assign() to allow user to enter Location and Budget

Display() to display Location and Budget

#### 03A-2019S-C1 #6987

( As In Exam - CBSE12A-2019 )

Write a user-defined function NoTwoThree(int Arr[], int N) in C++, which shou

Write a user-defined function NoTwoThree(int Arr[], int N) in C++, which should display the value of all such elements and their corresponding locations in the array Arr (i.e. the array index), which are not multiples of 2 or 3. N represents the total number of elements in the array Arr, to be checked.

Example: If the array Arr contains

0          1           2         3          4

 25 8 12 49 9

Then the function should display the output as:

25 at location 0

49 at location 3

#### 03A-2019S-C2 #6992

( As In Exam - CBSE12A-2019 )

Write a user-defined function ReArrange(int Arr[], int N) in

Write a user-defined function ReArrange(int Arr[], int N) in C++, which should swap the contents of the first half locations of the array Arr with the contents of the second half locations. N (which is an even integer) represents the total number of elements in the array Arr.

Example :

If the array Arr contains the following elements (for N=6)

0          1           2         3          4     5

 12 5 7 23 8 10

Then the function should rearrange the array to become:

0            1          2        3         4       5

 23 8 10 12 5 7

NOTE:

• DO NOT DISPLAY the Changed Array contents.
• Do not use any other array to transfer the contents of array Arr.

#### 03B-2019S-C1 #6994

( As In Exam - CBSE12A-2019 )

Write definition for a function XOXO(char M) in C++, which replaces eve

Write definition for a function XOXO(char M) in C++, which replaces every occurrence of an X with an O in array, and vice versa.

For example:

 ORIGINAL ARRAY M X X O X O X O O O O X X X X O O

 CHANGED ARRAY M O O X O X O X X X X O O O O X X

NOTE:

• DO NOT DISPLAY the Changed Array contents.
• Do not use any other array to transfer the ontents of array M.

#### 03B-2019S-C2 #6997

( As In Exam - CBSE12A-2019 )

Write definition for a function ColSwap(int A) in C++, which swaps the

Write definition for a function ColSwap(int A) in C++, which swaps the contents of the first column with the contents of the third column.

For example:

 ORIGINAL ARRAY A 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85

 CHANGED ARRAY A 20 15 10 25 40 35 30 45 60 55 50 65 80 75 70 85

NOTE:

• DO NOT DISPLAY the Changed Array contents.
• Do not use any other array to transfer the ontents of array A.

#### 03C-2019S-C1 #7003

( As In Exam - CBSE12A-2019 )

Let us assume P is a two-dimensional array, which is stored in the me

Let us assume P is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes, find the address of the elements P, if the address of the element P is 25000.

#### 03C-2019S-C2 #7005

( As In Exam - CBSE12A-2019 )

Let us assume P is a two-dimensional array, which is stored in the me

Let us assume P is a two-dimensional array, which is stored in the memory along the column with each of its elements occupying 2 bytes. Find the address of the element P, if the base address of array is 25000.

#### 03D-2019S-C1 #7007

( As In Exam - CBSE12A-2019 )

Write a user-defined function Pop(Book B[], int &T), which pops the detai

Write a user-defined function Pop(Book B[], int &T), which pops the details of a Book, from the stack of Book B, at the location T (representing the Top end of the stack), where every Book of the stack is represented by the following structure:

```Struct Book
{
int Bno;
char Bname;
};```

#### 03D-2019S-C2 #7009

( As In Exam - CBSE12A-2019 )

For the following structure of Books in C++

```Struct Book
{
int

```

For the following structure of Books in C++

```Struct Book
{
int   Bno;
char  Bname;
};

```

Given that the following declaration of class BookStack in C++ represents a dynamic stack of Books:

```class BookStack
{
Book*Top; // inter with address of Topmost book of Stack
public:
BookStack()
{
Top = NULL;
}
void Push();  //Function to push a Book into the dyanmic Stack
void Pop(); Function to pop a Book from the dynamic stack
~BookStack();
};```

#### 03E-2019S-C1 #7011

( As In Exam - CBSE12A-2019 )

Evaluate the following Postfix expression, showing the stack contents:

Evaluate the following Postfix expression, showing the stack contents:

250,45,9,/,5,+,20,*,-

#### 03E-2019S-C2 #7014

( As In Exam - CBSE12A-2019 )

Convert the following Infix expression to its equivalent Postfix expression ,

Convert the following Infix expression to its equivalent Postfix expression , showing  the stack contents for each step of converson:

A + B * C ^ D – E

#### 04A-2019S-C1 #7018

( As In Exam - CBSE12A-2019 )

A text file named MESSAGE.TXT contains some text. Another te

A text file named MESSAGE.TXT contains some text. Another text file named SMS.TXT needs to be created such that it would store only the first 150 characters from the file MESSAGE.TXT.

Write a user-defined function LongToShort() in C++ that would perform the above task of creating SMS.TXT from the already existing file MESSAGE.TXT.

#### 04A-2019S-C2 #7020

( As In Exam - CBSE12A-2019 )

A text file named CONTENTS.TXT contains some text. Write a user-defined funct

A text file named CONTENTS.TXT contains some text. Write a user-defined function LongWords() in C++ which display all such words of the file whose length is more than 9 alphabets. For example: if the file CONTENTS.TXT contains:

“Conditional statements of C++ programming language are if and switch”

Then the function LongWords() should display the output as:

Conditional

statements

programming

#### 04B-2019S-C1 #7023

( As In Exam - CBSE12A-2019 )

Write a user-defined function TotalPrice() in C++ to read each object of a bi

Write a user-defined function TotalPrice() in C++ to read each object of a binary file STOCK.DAT, and display the Name from all such records whose Price is above 150. Assume that the file STOCK.DAT is created with the help of objects of class Stock, which is defined below:

class Stock
{
char Name; float Price;
public:
char* RName() { return Name; }
float RPrice() { return Price; }
};

#### 04B-2019S-C2 #7026

( As In Exam - CBSE12A-2019 )

A binary file DOCTORS.DAT contains records stored as objects of the following

A binary file DOCTORS.DAT contains records stored as objects of the following class:

```class Doctor
{
int DNo; char Name; float Fees;
public;
int *GetNo() { return DNo; }
void Show()
{ cout<<Dno<<"*"<<Name<<"*"<<Fees<<endl; }
};```

Write definition for function Details(int N) in C+, which displays the details of the Doctor from the file DOCTORS.DAT, whose DNo matches with the parameter N passed to the function.

#### 04C-2019S-C1 #7030

( As In Exam - CBSE12A-2019 )

Find the output of the following C++ code considering that the binary file ST

Find the output of the following C++ code considering that the binary file STOCK.DAT exist on the hard disk with the following 5 records for the class Stock containing Name and Price .

 Name Price Rice 110 Wheet 60 Cheese 200 Pulses 200 Sauce 150
```void main()
{
fstream File
File.open("STOCK.DAT,ioc::binary|ios::in);
Stock S;
for (int I=1; I<=2; I++)
{
File.seekg((2*I-1)*sizeof(S));
}
File.close();
}```

#### 04C-2019S-C2 #7038

( As In Exam - CBSE12A-2019 )

Differentiate between seekg() and tellg().

Differentiate between seekg() and tellg().

Solved Problems #### Palindrome numbers between 1 to 1000 #1553

Print all palindrome numbers between 1 to 1000.

Print all palindrome numbers between 1 to 1000.

#### Displaying multiple String Literals #1563

Write a C++ code to display the following text “I am happy today.”

Write a C++ code to display the following text “I am happy today.” using four separate string literals and by using the same cout instruction.

#### Armstrong numbers between 1 to 999 #1566

Print all the armstrong numbers between 1 to 999.

Print all the armstrong numbers between 1 to 999.

#### Linear search function for search term presence and location #1632

Write a function linsearch(int [],int, int) which searches for the term 23 in

Write a function linsearch(int [],int, int) which searches for the term 23 in the given integer array [12,19,23,3,2] and returns its position in the array. This array should be initialised in the calling function and then passed as reference to the given function. Show implementation also.

#### Increment, Decrement Composite Operators Problem 1 #1756

Show the output of the following program. Assume that required header files a

Show the output of the following program. Assume that required header files are present.

```int main()
{
int n=10;
cout<< n << endl ;
cout<< ++n << endl ;
cout<< n++ << endl ;
cout<< n << endl ;
cout<< - n << endl ;
cout<< - - n << endl ;
cout<< -- n << endl ;
cout<< n << endl ;
cout<< n-- << endl ;
cout<< n << endl ;
cout<< - --n <<endl;
cout<< (n+=1) <<endl;
cout<< (n-=1) <<endl;
cout<< (n%=2) <<endl;
return 0 ;
}```

#### Finding Identifiers and Literals #1778

Write down identifiers and literals in the code given here.

Write down identifiers and literals in the code given here.

```int main()
{
int a=5;
cout<<"a="<<a<<endl;
float b=3.5;
double c=4.56;
cout<<"b="<<b<<endl;
cout<<"c="<<c<<endl;
cout<<"Sum of a+b+c = "<<a+b+c<<endl;
return 0;
}```

#### Checking for valid Identifiers #1782

Find the valid and invalid identifiers in the following piece of code segment

Find the valid and invalid identifiers in the following piece of code segment.

```int argument=123;
char c#='#';
float amar_is_a_beautiful_boy=3.45;
int taj mahal=1;
int break=0;
string file.ext="myfile.txt";
cout<<argument<<endl;
cout<<c#<<" "<<amar_is_a_beautiful_boy<<" "<<taj mahal<<endl;
cout<<break<<file.ext<<endl;

```

#### Sum of natural numbers up to a value given by the user. #2005

Write a c++ program to collect a positive integer value from the user and pri

Write a c++ program to collect a positive integer value from the user and print the list of all natural numbers up to that number. Also print the sum of the natural number printed.

#### Leap year finding #2008

Write a c++ program to take the value of a four digit year from the user and

Write a c++ program to take the value of a four digit year from the user and then print whether the given year is a leap year or not.

#### Even odd test #2012

Write a c++ program to test if the user given integer value is an even number

Write a c++ program to test if the user given integer value is an even number or an odd number.

#### Output writing – If-else with post/pre increment #2014

Write the output of the following c++ program when the user input value are -

Write the output of the following c++ program when the user input value are -1 and 1.

```int main()
{
int n;
cout<<"Enter and integer :";
cin>>n;
if(n++ >= ++n)
cout<<n<<" if";
else
cout<<++n<<" else";
return 0;
}```

#### Print all divisors and count of divisors #2016

Write a c++ program to ask an integer number from the user and then print all

Write a c++ program to ask an integer number from the user and then print all its divisors in one line, followed by the count of divisors. The output should be as per example given below.

Enter an integer :45
The divisors of 45 are –
1 3 5 9 15 45
The count of divisors = 6

#### Output writing – double increment in loop #2031

Write the output of the following code. Assume that required header files are

Write the output of the following code. Assume that required header files are included.

```int main()
{
for(int i=10;i<=50;i+=10)
cout<<i++/2<<" ";
return 0;
}```

#### Printable ascii codes #2045

Write a c++ program to print ascii codes and given printable characters from

Write a c++ program to print ascii codes and given printable characters from decimal ascii code 32 to 126 (The printable ascii code range). Print each code and character set in a new line.

#### Secret code with alphabet divisible by five #2047

Instead of sending his secret code a programmer tells his friend that my secr

Instead of sending his secret code a programmer tells his friend that my secret code is a series of characters which are upper and lower alphabet sequence in their ascending order which are divisible by five. Can you help the programmer’s friend to decipher this code.

#### Square and square root of numbers in a range #2049

Write a c++ program to output the square and square roots of a number in a ra

Write a c++ program to output the square and square roots of a number in a range where range begin variable is initialised in the variable ‘from’ and range end variable is initialised in the variable ‘to’.

#### Powering a number using a loop #2053

Write a c++ program to power a base number with the given exponent by using a

Write a c++ program to power a base number with the given exponent by using a for loop.

#### Excluding Numbers divisible by 2 or by 3 #2094

Write the output of the following program. Assume that required header files

Write the output of the following program. Assume that required header files are included.

```int main()
{
for(int i=1;i<=30;++i)
{
if(i%2==0 || i%3==0) continue;
else cout<<i<<" ";
}
return 0 ;
}```

#### Print next alphabet if possible #2157

Write a c++ program to collect an alphabet from the user and then print the n

Write a c++ program to collect an alphabet from the user and then print the next alphabet using the getchar(),  putchar() and isalpha() functions. Give suitable error message if next character is not an alphabet or the given entry by the user is not an alphabet.

#### Count punctuation in user given text stream (using get) #2167

Write a program to find punctuation in the user given text data. Use the func

Write a program to find punctuation in the user given text data. Use the function ispunct() for finding punctuation and use get() function of cin method to collect the user given text matter in a loop.

#### Count punctuation in user given text stream (using getline) #2173

Write a program to find punctuation in the user given text data. Use the func

Write a program to find punctuation in the user given text data. Use the function ispunct() for finding punctuation and use getline() function of cin method to collect the user given text matter in a loop.

#### Repeating a character using loop #2218

Write a program to repeat the character as given by the user for number of ti

Write a program to repeat the character as given by the user for number of times as desired by the user. Show the repeated character in the same line. Use for loop for repeatition.

#### Product of single 2D matrix members #2229

Write a program to find the product of all members of any 2D Matrix whose siz

Write a program to find the product of all members of any 2D Matrix whose size and data member values are given by the user. Assume that maximum size of matrix can be 10×10.

#### Print formatting using \t and \n escape sequences #2303

Write the following text using the cout chain using \t and \n escape sequenc

Write the following text using the cout chain using \t and \n escape sequences.

```Subjects        Marks
---------------------
Computers       100
Physics         95
Mathematics     98```

#### Converting input char to int and print ascii #2307

Write a c++ program to collect a single character from the user and print asc

Write a c++ program to collect a single character from the user and print ascii code of the same character and its next character.

#### Assignment, equality comparison problem #2314

Find the output of the program given below. Assume all relevant header files

Find the output of the program given below. Assume all relevant header files are included

```int main( )
{
int a,b,c=101,d=102;
a=(c=d);
cout<<a<<endl;
b=(c==d);
cout<<b<<endl;
return 0 ;
}```

#### Output of a ternary operator operation #2321

Write output of the following program using the ternary operation logic.

Write output of the following program using the ternary operation logic.

```#include <iostream.h>
int main()
{
int a=10,b=23;
int c=a>b?a=b:b=a;
cout<<c<<endl;
return 0;
}```

#### Search in 2D Array #2325

Write a program to search the presence of user given input number in a 2 dim

Write a program to search the presence of user given input number in a 2 dimensional array of
3 rows and 4 colums preinitialised with some numbers. The search output should be row/col of search location if found, else report “Not Found”. Assume that all members of array contain different values.

#### Average of three integer numbers, double output #2331

Write a C++ program to find average of three integer numbers given by the use

Write a C++ program to find average of three integer numbers given by the user. The output can have fractional double precision values as well.

#### Identify errors in fractional constants #2336

In the following representation of fractional constants, some of them may con

In the following representation of fractional constants, some of them may contain errors in representation. Identify them and explain the reasons.

1)   +123.45

2)   34.45-

3)   5.32E-2

4)   7.89E4.5

5)   00.035

#### Identify errors in the variable names #2342

Identify errors in the following variable names and suggest the best alternat

Identify errors in the following variable names and suggest the best alternative name(s) for the given variable.

1)   Alt-text
2)  3M_Company
3)  interest#5
4)  P\$
5)  (WonderDrug)

#### Output writing – loop with unary operators in cout chain #2346

Solve the following program to show its output. Assume that required header f

Solve the following program to show its output. Assume that required header files are included

```int main()
{
int a,b;
a=(b=10);
for(int i=10;i<30;i+=10)
{
cout<<a++ + i<<" "<<(b=++b -i)<<endl ;
}
return 0;
}

```

#### Switch case with fall through example. #2371

Write the output of the following code based on the switch-case selection whe

Write the output of the following code based on the switch-case selection when the user input is B, L, D or S. Assume inclusion of appropriate header files.

```int main ( )
{
char m;
cout<<"Enter meal type (B/L/D): ";
cin>>m;
switch (m)
{
case 'B':
case 'b':cout<<"Have some thing. ";
case 'L':
case 'l':cout<<"Come to Dining Table.";break;
case 'D':
case 'd':cout<<"Let's go outside."; break;
default: cout <<"Error in input";
}
return 0 ;
}```

#### Simple interest program with function. #2386

Write a c++ program to define a function si(p,r,t) with input parameters as p

Write a c++ program to define a function si(p,r,t) with input parameters as p, r and t for principal, rate and term and let it return no data. The calculated value of interest may be saved in a global variable.
Also show the demonstration of working of this function by calling it in the main() routine by passing some fixed values of p,r and t. In the main routine print the final amount by adding the interest to the principal amount.

#### Two previous terms addition series (like Fibonacci) from another number. #2413

Assume that first two terms of a series are 10 and 11. Then use the Fibonacc

Assume that first two terms of a series are 10 and 11. Then use the Fibonacci series rules of adding two previous terms, write a program to print 10 terms of such a series. Also print the sum of all the terms printed.

#### Odd number series beginning a given number and given term count #2418

Write a program to print odd numbers series up to 20 terms beginning from 13.

Write a program to print odd numbers series up to 20 terms beginning from 13.

#### Cube series #2420

Write a program to print the following series up to 15 terms ..
1 8 27

Write a program to print the following series up to 15 terms ..
1 8 27 64 125 …….

#### Gap increment series #2422

Write a program to print the following series up to 15 terms ..
1 4 8

Write a program to print the following series up to 15 terms ..
1 4 8 13 19 26 …….

#### Printing Terms and Sum of geometric series x+x^2/2+..+x^n/n #2438

Write a program to find the sum of the following series if x is 3 and n is 5

Write a program to find the sum of the following series if x is 3 and n is 5. Also print the series terms.
x + x^2/2 + x^3/3 + …+x^n/n

#### Printing and summing series 1/n! form. #2443

Write a program to find the sum of the following series upto 5 terms. Also pr

Write a program to find the sum of the following series upto 5 terms. Also print the series terms.
1/1! + 2/2! + …

#### Average of temperature values stored in array #2487

Write a program to store 10 temperature readings in an array and then find th

Write a program to store 10 temperature readings in an array and then find the average temperature of the given readings.

#### Comparing two names for sort order #2577

Write a program using the strcmp() function to prove that the name RAKESH wi

Write a program using the strcmp() function to prove that the name RAKESH will come before the name RAMESH in an
ascending order sorted list.

#### First word of sentence (by individual character printing) #2594

Write a program to print the first word of a sentence given by the user.

Write a program to print the first word of a sentence given by the user.

#### First word of sentence (by creating another null terminated string) #2601

Write a program to print the first word of a sentence given by the user by cr

Write a program to print the first word of a sentence given by the user by creating another null terminated string.

#### count number of spaces in a given sentence #2614

Write a program  to count the number of space characters in a given input st

Write a program  to count the number of space characters in a given input string or sentence using the character match for space character ‘ ‘.

#### Change case of string input #2625

Write a program to get input of a string from the user as a character array a

Write a program to get input of a string from the user as a character array and then print the output with changed case from lower to upper and upper to lower for every character present in it. Do not taken any action if the character is not an alphabet, just print as it is.

#### Removing vowels from string #2628

Write a program to collect input sentence from user into a character array as

Write a program to collect input sentence from user into a character array as a null terminated string. Reprint the user given sentence after removing all the vowels. You can use switch case or if-else to check the vowel condition.

#### Word count assuming well formed sentence #2632

Write a program to count words in a given input sentence by a user, assuming

Write a program to count words in a given input sentence by a user, assuming that the sentence is well formed in a way that there are no initial or leading spaces and no extra spaces between words.

#### output writing example strcpy, strcat #2649

Write the output of the following program.

Write the output of the following program.

#### output writing, pass by ref/pass by value #2652

Write the output of the following code piece.

Write the output of the following code piece.

#### Char array passing to function #2656

Write a function alpha_count() where a character array is passed as reference

Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so.

#### Output writing – passing string as char pointer #2659

Write output of the following code.

Write output of the following code.

#### Simple Interest function with default parameter values. #2661

Write output of the following program. Please do take care about the default

Write output of the following program. Please do take care about the default parameters given while calling the function.

#### Trailing default parameters check #2666

A c++ program given here has some errors. Please correct the errors to make i

A c++ program given here has some errors. Please correct the errors to make it a working program. Assume any data values required to make it working correctly.

#### Character replacements in a string #2673

Write a c++ program to collect a small sentence from the user and then print

Write a c++ program to collect a small sentence from the user and then print the same sentence with all spaces replaced by hyphen (dash) character and all alphabets are replaced by their lower case counterparts.

#### Output Writing – isupper(), islower, isalpha() #2677

Write output of the following program.

Write output of the following program.

#### Array to array data #2697

Write output of the following code and explain its working.

Write output of the following code and explain its working.

#### Output writing function within function with array passing #2746

Dry run the following program carefully and write the output.

Dry run the following program carefully and write the output.

#### Counting words in a text input even if it is not well formed #2717

Write a program to count number of words even when there might be extra space

Write a program to count number of words even when there might be extra spaces between words and extra punctuation marks. Any alphabets or numbers written contiguously will be counted as words. For. e.g. “21st Century” are two words and “21    st         century systems ?” are four words. ? is not counted as word while 21 is counted as a word.

#### Correcting error in function call by reference #2742

Program given below has some incorrectly written function call, correct the m

Program given below has some incorrectly written function call, correct the mistake and rewrite the
program.

#### Setting bigger of two values using function returning reference #2757

Write a c++ program using function returning the reference which finds the b

Write a c++ program using function returning the reference which finds the bigger of two variables
passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also.

#### Collect student details to structure and update selectively #2781

Write a program to collect follow entry about an student in a structure type

Write a program to collect follow entry about an student in a structure type c++ data structure.
integer – rollno, char array – name, float – marks and char passfail. Declare a global instance of this structure and then collect the rollno,name and marks in the main routine. Within the main routine update the value of passfail as ‘Y’ or ‘N’ if the marks are more than or equal to 33.0 . Finally it should report as per following example.

R.No. Name Marks Status
———————————
22       Vijay  45         Pass

#### Ternary operator within cout chain for selective printing #2791

Initialise a character variable. Now using the ternary operator within the co

Initialise a character variable. Now using the ternary operator within the cout chain of printing, print YES if initialised variable is Y and print NO if it is anything else.

#### Find presence of a character in a null terminated string. #2840

Write a program to get a sentence from the user and then a single character f

Write a program to get a sentence from the user and then a single character from the user. Find if the character entered by the user is present in the given sentence or not.

#### Proving palindrome array #2848

Write a program to prove that the give array [23,43,51,43,23] is a palindrome

Write a program to prove that the give array [23,43,51,43,23] is a palindrome array, means that its reversed pattern will be same as its original pattern.

#### Triangular Number series using the Flyod’s triangle method #2860

Write a program to print a series of triangular numbers starting 1 using the

Write a program to print a series of triangular numbers starting 1 using the property of a flyod’s triangle where the right most number is a triangular number. Accept the number of terms to be printed from the user. The series output would be 1 3 6 10 15 ……

#### Nested Structure Initialisation #2928

Write the output of the following program.

Write the output of the following program.

#### Largest of three numbers using if else ladder #2946

Write a c++ program to find the largest of three numbers using the if-else se

Write a c++ program to find the largest of three numbers using the if-else selection ladder. Please do report with an appropriate message if two large numbers or all numbers are same.

#### Function to return largest of three numbers along with all same check #2951

Write a function to return the largest of three integer numbers passed to it

Write a function to return the largest of three integer numbers passed to it as value. Also pass a variable as reference which will be set to 1 if all the numbers passed are same. Show implementation of this function in the main routine with appropriate messages.

#### Finding errors in structure declaration #2961

```Find the errors in the following structure declaration.

struct Computer

```
```Find the errors in the following structure declaration.

struct Computer {
char type="Laptop";
char p;
Computer comp;
float price;
};c1```

#### Output writing using strcpy for structure string variables #2964

Write the output of the following program. Assume that required header files

Write the output of the following program. Assume that required header files are present.

```struct Game {
char Magic;int Score;
};

int main()
{
Game M={"Tiger",500};
char a;
cout<<M.Magic<<", "<<M.Score<<endl;
strcpy(a,M.Magic);
a='L'; a='o'; a='n'; a='';
strcpy(M.Magic,a);
M.Score++;
cout<<M.Magic<<", "<<M.Score<<endl;
return 0;
}```

#### Slope of line -using structure Point passed to a function #2973

Write a program by declaring a structure Point with two integer values for i

Write a program by declaring a structure Point with two integer values for its position x and y. Now write a function that finds slope of a line drawn out of two points that are passed as structure argument to this function. Show implementation of this function and structure in the main routine assuming suitable values of x and y being initialised for two points.

#### Output Writing Structure pass by value/reference #2984

Write the output of the following program depicting structure instances being

Write the output of the following program depicting structure instances being called as value and called as reference to a function.

```struct Sale {int ID; float value;};
void sc(Sale a,Sale &b)
{
a.ID=a.ID+1;
a.value=a.value+100;
b=a;
}
int main()
{
Sale zone1={1,400.50},zone2;
sc(zone1,zone2);
cout<<"Zone 1 (ID, value) = "<<zone1.ID<<", "<<zone1.value<<endl;
cout<<"Zone 2 (ID, value) = "<<zone2.ID<<", "<<zone2.value<<endl;
return 0;
}```

#### Output Writing – Pixel structure passed by reference #2987

Write down the output of the program and give steps in arriving at such outpu

Write down the output of the program and give steps in arriving at such output.

```struct Pix {int x,y;};
void show(Pix &p)
{
cout<<p.x++<<","<<++p.y<<endl;
}
int main()
{
Pix P={50,60},Q,R;
R=P;
show(R);
P.x+=10;P.y+=30;
Q=R;
show(P); show(Q); show(R);
return 0;
}```

Write a c++ program using function overloading using the following prototype –
int area(int); //For area of square
float area(float); //For area of circle
int area(int,int); //For area of rectangle
show working of this program by calling this function into the main routine using some assumed valued.

#### Error checking switch-case (char-int check) #2994

Following program may compile and link well but still it may not serve the de

Following program may compile and link well but still it may not serve the desired purpose. Find the error.

#### Finding Errors #2997

Find errors in the following program and write the program with correct synt

Find errors in the following program and write the program with correct syntax.

#### For to while conversion #3001

Write the following program again using the while loop instead of for loop

Write the following program again using the while loop instead of for loop

#### First and last digit of an integer in a function and putting at reference location #3018

Write a c++ program using a function with the following prototype –

Write a c++ program using a function with the following prototype –
void first_last_digit(int n,int first,int last);
In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine.

#### Displaying long cout chains #3060

Write a C++ code to display the following text using the same cout chain.

Write a C++ code to display the following text using the same cout chain.
Apples = 5 Kg
Bananas = 2 Doz
Oranges = 2.5 Kg

#### gallons to cubic centimeters unit conversion #3066

Convert given user input in gallons to cubic centimeter.  fter conversion u

Convert given user input in gallons to cubic centimeter.  fter conversion use the converted quantity back to gallons. Print both the values. Assume appropriate data types.
Use conversion of 1 gallon = 3785.41 cc.

#### multiples of an integer #3070

Write a program to display 2nd, 4th and 6th multiple of the input integer num

Write a program to display 2nd, 4th and 6th multiple of the input integer number.

#### Reversing each word in a sentence #3073

Write a program to take a sentence input from the user and then print the sen

Write a program to take a sentence input from the user and then print the sentence by reversing each word in the sentence.

#### Test palindrome for an integer number #3082

Write a program where a function of prototype int ispalin(int) is written, wh

Write a program where a function of prototype int ispalin(int) is written, which returns 1 when
given input number is a palindrome (eg. 121, 16561) else returns 0. Show implementation of this function in main routine by collecting a positive integer from the user.

#### function to reverse an integer #3086

Write a program to reverse the given integer number.using a separately called

Write a program to reverse the given integer number.using a separately called function to reverse the number.

#### Sum of integer array #3088

Write a program to collect 5 integer values from user in an integer array an

Write a program to collect 5 integer values from user in an integer array and then pass this array to a function along with its size. Return the sum of the array members from the function and print its value in the main routine.

#### Average value of array and members more than average #3098

Prepare an array of temperature readings of an entire week with data as

Prepare an array of temperature readings of an entire week with data as
25.3, 27.0, 24.8, 26.9, 25.9, 26.4, 24.0. Now find out the average temperature of the week and then print out the readings which are more than the average temperature.

#### Square or cube based on even check selection #3122

Write a program which collects an integer number from the user and if the nu

Write a program which collects an integer number from the user and if the number is even it prints the square of the number else it prints its cube.

#### Finding errors – Programming basics #3159

Find the errors in the following code and explain.

Find the errors in the following code and explain.

#### Finding Errors – Escape Sequences #3164

There are some errors in the following code due which the expected output as

There are some errors in the following code due which the expected output as given below will not come
“C++” is tricky & powerful

#### Finding input variables errors #3190

Find error in the following program and suggest corrections. Assume that incl

Find error in the following program and suggest corrections. Assume that includes and namespace is already given.

#### Output writing implicit typecasting #3208

Write output of the following program if the input given is R

```int ma

```

Write output of the following program if the input given is R

```int main()
{
char x, y=32;
cout<<"Input an uppercase alphabet: ";
cin>>x;
char c=x+y;
int d=x+y;
cout<<"Output 1 would be "<<c<<endl;
cout<<"Output 2 would be "<<d<<endl;
return 0;
}```

#### Output Writing – Logical Operators #3215

Write the output of the following program and explain.

```int main( )

```

Write the output of the following program and explain.

```int main( )
{
int a=1,b=0;
int c=!a && b;
cout<<(c || b+a)<<endl;
cout<<(-c && a+b)<<endl;
return 0 ;
}```

#### Suggesting Error Corrections in Natural Number Addition #3221

A student has written this program to sum natural numbers from 1 to 10. His�

A student has written this program to sum natural numbers from 1 to 10. His program is not giving correct results. Please help in correcting this program with right explanations as well.

#### Frequency of a given character in a sentence #3243

Write a program to input a small sentence from the user and ask about frequen

Write a program to input a small sentence from the user and ask about frequency of which character is to be found. Print how many times the character occurred in the given string. Do it for a a c-style (null-terminated string). Please note that the character frequency is to be found  irrespective of its lower or upper case.

#### Output writing – If-else ambiguities #3249

Write output of the following code. Assume that required header files are inc

Write output of the following code. Assume that required header files are included.

```int main()
{
int x=10,y=20;
if(x=0) cout<<"Hello"<<endl;
else cout<<"Sorry"<<endl;
if(y=10) cout<<"Hello"<<endl;
else cout<<"Sorry"<<endl;
if(x+y==10) cout<<"Hello"<<endl;
else cout<<"Sorry"<<endl;
return 0;
}```

#### Check if number is a palindrome without using modulus operator #3581

Write a C++ program to collect a positive integer from the user and the check

Write a C++ program to collect a positive integer from the user and the check its reversed number would be a palindrome or not (same number when reversed for e.g. 121, 1331). Please use some alternate technique to find remainder instead of modulus operator.

#### problem based on setw, setf and unsetf #4321

print the following table of temperature record of a patient properly using

print the following table of temperature record of a patient properly using setw,setf,unsetf methods.

```Readings   Values
-----------------
Morning     100.4
Afternoon    99.8
Evening      98.8```

#### Token Identification #4431

Identify the type of token (literal, identifier, keyword, punctuator etc.) in

Identify the type of token (literal, identifier, keyword, punctuator etc.) in the following
1) Case    2) { }    3) break      4) O17

Mark the name of required C++ header files for each of the following function

Mark the name of required C++ header files for each of the following functions
strlen
getline
exit(0)
tolowerfloor

#### Error finding in function and related code #4447

Find syntactical errors in the following program and rewrite the program afte

Find syntactical errors in the following program and rewrite the program after underlining the corrected portion.

#include<iostreamh>
using namespace std;
void toUpper(char x) {return ((char) (x+1));}
main()
{
char c, String[]=”DOGS ARE NOT CATS”;
for(int i=0;String[i]!=;i++)
if(String[i]==’ ‘) cout<<endl;
else { c=toUpper(String[i]);cout<<c;}
return 0;
}

Write two overloaded functions as follows:

Function 1:
Convert i

Write two overloaded functions as follows:

Function 1:
Convert integer input parameter which is a number given as inches of some measurement to a double number which is of centimeter measurement

Function 2:
Convert double input parameter which is a number given as inches of some measurement to a double number which is of centimeter measurement

use conversion formula as 1 inch = 2.54 cm.

Also show the implementation of both the functions in the main routine.

#### Swapping first and last row #5000

Write a user-defined function swap_row(int ARR[ ],int R,int C) in C++ to

Write a user-defined function swap_row(int ARR[ ],int R,int C) in C++ to swap the first row values with the last row values:

For example if the content of array is –
10 20 30
40 50 60
70 80 90

Then after function call the content of array would be

70 80 90
40 50 60
10 20 30

#### Swapping first and last column #5004

Write a user-defined function swap_col(int ARR[ ],int R,int C) in C++ to

Write a user-defined function swap_col(int ARR[ ],int R,int C) in C++ to swap the first column values with the last column values:

For example if the content of array is –
11 12 13
21 22 23
31 32 33

Then after function call the content of array would be

13 12 11
23 22 21
33 32 31

#### Tee Shirts Selection By Sports Teacher #5011

A sports teacher has been confidentially asked to reject the persons whose Te

A sports teacher has been confidentially asked to reject the persons whose Tee-shirt numbers are divisible by 10. Make a program to help this teacher collect the T-shirt numbers one by one and stop counting when 10 persons have been counted. Keep printing the selected Tee-shirt numbers.

#### Count alphabets in a file #5026

Write a program to count alphabets in a given file “NOTES.TXT”.

Write a program to count alphabets in a given file “NOTES.TXT”. What would be  the output when this file is tested with the NOTES.TXT  file containing the following lines.

This is first line
This is second line
This is third line

#### Finding student division using a function #5032

Write a function named DIVISION to pass maximum marks and marks obtained by

Write a function named DIVISION to pass maximum marks and marks obtained by a student. Return division as integer value 1, 2 3 or 0 as follows

=60 % as first division – return 1
>=45 <60 % as Second Division – return 2
>=33 <45 % as Third Division – return 3
<33 as Fail – return 0

Show implementation of above function in main routine with some fixed values.

#### Count Words in a Text File #5034

Write a function to count and return the number of words present in the filen

Write a function to count and return the number of words present in the filename passed to it as an argument. Assume that each word is separated by a single space and their is no space in the
beginning and end of the file.

Also demonstrate the use of this function in the main routine assuming a file NOTES.TXT that contains the following text.

This is first line
This is second line
This is third line

#### Count Spaces in a Text File #5036

Write a function to count and return the number of space characters present i

Write a function to count and return the number of space characters present in the filename passed to it as an argument. Also show implementation of this function in the main routine using NOTES.TXT file that contain the following data

This is first line
This is second line
This is third line

#### Displaying and counting lines starting with a certain character #5039

Write a program to display the lines starting with character ‘A’

Write a program to display the lines starting with character ‘A’ or ‘a’ in the file “PROG.TXT” that contains following text. Also display the count of such lines.

A programmer should always be hardworking.
For that matter everyone should be hardworking.
A programmer is always under pressure.
Yes! not everyone is always under pressure.

#### Displaying three character words in a file #5044

Write a program to display all the words in a file that are three character w

Write a program to display all the words in a file that are three character words. Assume that filename is
MATTER.TXT and it contains the following matter.

The quick brown fox jumps over a lazy dog

#### Required header files in a file handling program #5046

Raju is trying to run the following program in his compiler, but he is unable

Raju is trying to run the following program in his compiler, but he is unable to do the some due to absence of some header files he forgot to include. Please help him.

```int main()
{
ifstream ipfile("LIST.TXT",ios::in);
char ch;
while(!ipfile.eof())
{
ipfile.get(ch);
if(isdigit(ch)) cout<<ch<<" ";
}
ipfile.close();
return 0;
}```

#### Output Writing Based on char and int array reference #5051

Write output of the following code. Assume that all relevant header files hav

Write output of the following code. Assume that all relevant header files have been added.

```int main()
{
char *text = "AJANTA";
int *p, num[]={1,5,7,9};
p=num;
cout<<*p<<text<<endl;
text++;
p++;
cout<<*p<<text<<endl;
}```

#### Output Writing – Modifying and Reading int array using a pointer variable #5054

Write output of the following code.

```int main()
{
int *striker, t

```

Write output of the following code.

```int main()
{
int *striker, track[] = {10,20,30,40};
striker=track;
track+=30;
cout<<"striker"<<*striker<<endl;
*striker-=10;
striker++;
cout<<"Next@"<<*striker<<endl;
striker+=2;
cout<<"Last@"<<*striker<<endl;
cout<<"Rest to"<<track<<endl;
return 0;
}```

#### Code error in class #5179

Find error (if any) in the following class definition.

```Class PLAY
{

```

Find error (if any) in the following class definition.

```Class PLAY
{
int number_of_actors=5;
void set_actor_count()
{
number_of_actors=10;
}
};```

#### Alphabet series #5182

Write a program to print the following alphabet series up to 7 terms.

Write a program to print the following alphabet series up to 7 terms.

C F I L …..

#### Error identification #5184

Identify errors in the following program. assume that appropriate header file

Identify errors in the following program. assume that appropriate header files are included.

```int main()
{
x=1;
for(int j=10; j>5; j--)
cout>>x;
return 0;
}```

#### Output Writing – Function Returning reference #5265

Write output of the following code. Assume inclusion of related header files.

Write output of the following code. Assume inclusion of related header files.

```int &min(int &a, int &b)
{
if (a<b) return a;
else return b;
}

int main()
{
int x=2,y=3;
min(x,y)=10;
cout<<"x-y = "<<(x-y)<<endl;
cout<<"y-x = "<<(y-x)<<endl;
return 0;
}```

#### Finding hypotenuse of a right angled triangle #5328

Write a program to print hypotenuse of a right angled triangle if base and h

Write a program to print hypotenuse of a right angled triangle if base and height of the triangle is given by the user.

#### comparing ceil, floor, round, abs function values #5330

Which of the following math function will return the lowest number as output

Which of the following math function will return the lowest number as output. Also write output of all functions.

(i) ceil(5.1)
(ii) floor(5.9)
(iii) round(5.99)
(iv) abs(-6)

#### Finding errors – Programming basics #5340

Find errors in the following code and explain. Assume that required header fi

Find errors in the following code and explain. Assume that required header files are present.

```main()
{
cout<<endl<<a;
return 0;
}```

#### Correct Identifiers #5343

Only 4 out of 10 names written below can be used as variable names or identi

Only 4 out of 10 names written below can be used as variable names or identifiers by a C++ programmer, can you name them.

4PIN
PIN_\$
Identifier
PIN_4
P.I.N.
numb_er
Srl.No.
_SIMPLE_INTEREST
FOUR@IDENTIIFERS
FOUR NAMES

#### Output writing – forming expression within cout #5345

Write output of the following code. Assume that related header files are incl

Write output of the following code. Assume that related header files are included.

```int main()
{
int a=10,b=13,c;
cout<<(c=a+b/a)<<" ";
cout<<(a=b+c);
return 0 ;
}```

#### Addition of Series of Numbers Increasing by 10 #5350

Write a program to find the sum of following series with any looping statemen

Write a program to find the sum of following series with any looping statement
12 + 22 + 32 ……… +72

#### Function for Addition of Series of Numbers Increasing by 10 #5354

Write a function to find the sum of following series with any looping stateme

Write a function to find the sum of following series with any looping statement
12 + 22 + 32 ……… +72

#### Evaluating expressions #5358

What will be the value of c after evaluating the given expressions on the lef

What will be the value of c after evaluating the given expressions on the left side for following two set of statements. Also justify your answer

```(i)  int j=5; int c=(5*++j)%6;
(ii) int j=5; int c=(5*j++)%6;```

#### Output writing – Three for loops #5362

Write the output of the following code. Assume all header files are included.

Write the output of the following code. Assume all header files are included.

```int main()
{
int i;
for(i=10; i>6; i=i-2) cout<<i<<" ";
cout<<endl;
for(i=-5; i> -8; i--) cout<<i+1<<" ";
cout<<endl;
for(i=-3,sum=0; i<3; i--) cout<<sum++<<" ";
cout<<endl;
return 0;
}```

#### Differences between structure and array #5366

Write the main differences between structure and array

Write the main differences between structure and array

#### Code Error Finding #5368

Rewrite the following program after removing possible compiler errors. Mark e

Rewrite the following program after removing possible compiler errors. Mark each correction by underlining it. Assume that relevant header files are included.

```int main()
{
const int d 5;
number = 15;
for(int i=1; i<=5; i++, number-=3)
if(number%d==0) cout<<number/d<<" ";
else cout<<number+d<<" ";
}```

#### Filling integer array members based on user input and summing them #5370

Write a program to collect 5 numbers from user into a 1-D integer array. Calc

Write a program to collect 5 numbers from user into a 1-D integer array. Calculate sum of all the input numbers and print it with a suitable message.

#### Collecting 2D Array members, Doubling and Printing #5372

Write a program to collect members of a 2-D integer array in A form. Do

Write a program to collect members of a 2-D integer array in A form. Double value of each member and then print the array in matrix form

#### Output writing – Pointer to string and integer array #5376

Find and write the output of the following C++ program code.

Find and write the output of the following C++ program code.

#### Finding Valid Multiple value assignments #5573

Which of the following statements is/are valid and why.
int x;

(

Which of the following statements is/are valid and why.
int x;

(i)  x=1,024;

(ii) x=(1,024);

#### Output writing – Possible Random Numbers Series #5591

Go through the C++ code below and find out the possible outputs from the sugg

Go through the C++ code below and find out the possible outputs from the suggested options (i) to (iv). Assume all the required header files are already being included in the code.

```void main()
{
const int LOW=25;
randomize();
int p=5, number;
for(int i=1; i<=4; i++)
{
number=LOW+random(p);
cout<<number<<":";
p--;
}
}```

(i)   29:26:25:25:             (ii)   24:28:25:26
(iii) 29:26:24:28             (iv)  29:26:25:25:

#### Output Writing – Three dimensions in structure passed by reference #5596

Write down the output of the program.

```struct three_d{int x,y,z;};

```

Write down the output of the program.

```struct three_d{int x,y,z;};

void movein(three_d &t,int step=1)
{
t.x+=step; t.y-=step; t.z+=step;
}
void moveout(three_d &t,int step=2)
{
t.x-=step; t.y+=step; t.z-=step;
}

int main()
{
three_d t1={10,20,5},t2={30,10,40};
movein(t1);
moveout(t2,5);
cout<<t1.x<<","<<t1.y<<","<<t1.z<<endl;
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
movein(t2,10);
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
return 0;
}

```

#### Searching elements from one array into another array #5617

Write a program to search members of integer array 1 in array 2 and print the

Write a program to search members of integer array 1 in array 2 and print the members of array 1 that are also found in array 1. Also print the total number of members found.
For e.g. if array 1 is [12,19,23,3,2] and array 2 is [13,12,2,3,14,21],
the output would be
12 3 2
count = 3

#### Output writing – pointer and pointer value increment for array #7500

Find and write the output of the following C++ program code.

```int mai

```

Find and write the output of the following C++ program code.

```int main( )
{
int Ar[]={1,3,8,10,4,6,7} ;
int *Ptr= Ar, I ;
cout<<++*Ptr++ << '@' <<endl;
for( int x=0; x<7 ;x++) cout<<Ar[x]<<" ";
cout<<endl;
I = Ar - Ar ;
cout<<++*(Ptr+I)<<'@';
cout<<Ar[I]<<'@';
return 0;
}
```

#### Finding Type and Member Accessibility #7635

Answer the questions (i) to (iv) based on the following:

```class Shape

```

Answer the questions (i) to (iv) based on the following:

```class Shape
{
int length;
protected:
int width,height;
public:
Shape();
void getDimension(int,int,int); void dispDimension();
};
class SideShape : protected Shape
{
int SideLength,SideWidth;
protected:
void getSide(int,int);
public:
SideShape();
void dispSide();
};
class SubShape : public SideShape
{
int subLength;
void display();
public:
SubShape();
void enter();
};
```

(i) Name the base class and derived class of SideShape
(ii) Write the name(s) of all the data members that can be accessed from function dispSide().
(iii) Write the name(s) of private member functions of class SubShape.
(iv) Write the names of all the member functions accessible from object of class SubShape.

#### Array of Structure – Output Writing #7663

Find and write the output of the following C++ program code:
Note: Assu

Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```struct Score {
int Year;float Topper;
};
void change(Score *s,int x=10)
{
s->Topper=(s->Topper+15)-x;
s->Year++;
}
int main()
{
Score Arr[]={{2006,100},{2007,85}};
Score *point=Arr;
change(point,40);
cout<<Arr.Year<<'#'<<Arr.Topper<<endl;
change(++point);
cout<<Year<<'#'<<Topper<<endl;
return 0;
}

```

#### Output writing using structure copy and strcat use #7684

```struct Play {char Arr;int n;};
int main()
{
struct Play P={"JUD

```
```struct Play {char Arr;int n;};
int main()
{
struct Play P={"JUDO",2};
P.Arr='L';
P.n+=2;
cout<<P.Arr<<"#"<<P.n<<endl;
Play R = P;
R.Arr='S';R.Arr='O';
strcat(R.Arr,"KU");
R.n-=3;
cout<<R.Arr<<"#"<<R.n<<endl;
return 0;
}```

Write the output of the above program. Assume that required header files are present.

#### Output writing using structure copy and strcat use #7691

```struct Employee{double salary,hra;};
void change(Employee &a,double h=

```
```struct Employee{double salary,hra;};
void change(Employee &a,double h=100)
{
a.salary+=1000;
a.hra+=h;
}
int main()
{
Employee A={5000,2000};
cout<<"Initial Payment  = "<<A.salary+A.hra<<endl;
change(A,500);
cout<<"After 1st Change = "<<A.salary+A.hra<<endl;
change(A);
cout<<"After 2nd Change = "<<A.salary+A.hra<<endl;
return 0;
}```

Write the output of the above program. Assume that required header files are present.

#### Output Writing – passing integers as ref and as def value #7699

Write the output of the following C++ program code:
Note: Assume all re

Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.

```void series(int x=10)
{
for(int i=2;i<=x;i+=2)
cout<<i<<" ";
cout<<endl;
}
void modify(int &n)
{
n*=2;
series(n);
}

int main()
{
int a=10;
cout<<"a="<<a<<endl;
modify(a);
series();
cout<<"new a="<<a<<endl;
return 0;
}```

#### Output writing – Pointer to string elements #7704

Find and write the output of the following C++ program code:
Note : Ass

Find and write the output of the following C++ program code:
Note : Assume all required header files are already included in the program.

```int main( )
{
char str[]="NOCONFUSION";
cout<<*str<<*(&str)<<endl;
cout.write(str,2)<<endl;
cout.write(str+2,9)<<endl;
return 0;
}```

#### Output writing – Pointer to string as char array #7709

Find and write the output of the following C++ program code:
Note : Ass

Find and write the output of the following C++ program code:
Note : Assume all required header files are already included in the program.

```void strpat(char *str)
{
for(int i=0;str[i]>0;i++)
{
for(int j=0;j<=i;j++)
{
cout<<str[j];
}
cout<<endl;
}
}
int main( )
{
char *t="CBSE";
strpat(t);
return 0;
}```

Practice Problem #### SA-Operators Set 1 #3255

Quizzes 