Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


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

An introduction presentation about JAVA as a programming language, its evolution and its primary concepts.

Let us understand few points about C++ as a programming language.

Options for C++ development either on a desktop/laptop or directly on the internet. are explained here.

Various tokens or basic building blocks defined in c++ are explained here.

Concept of keywords in a language and keywords as per c++11 standard are explained here.

Identifiers can be names given by the user/programmer or names other than keywords in the library files.

This video explains the types of c++ operators based on number operands and purpose.

Some rules related to C++ identifiers are as follows: Can be arbitrarily long alpha numeric (letters and numbers) sequence. The first character must be a letter. As an exception _ (underscore) is considered as a letter. Upper and lower case letters considered different All characters in the name are considered significant. C++ Keywords can not […]

There are many built-in functions in C++ which can be used by a programmer as needed. To allow a build-in function or usage of some pre-fixed declarations C++ provides a concept of header files. Header file primarily contains the function prototypes of built-in functions so that its type checking can be performed and related library […]

As C++ follows the Object Oriented Programming paradigm, it does implement the concepts of Abstraction and Encapsulation. These are interrelated concepts. First let us define them. Abstraction Abstraction is a concept where we talk about showing only the necessary part to the outside world and hide the details of implementation. Abstraction can be done for […]

Enumeration is basically a way to represent a possible list of number values for a variable in friendly names or symbol forms. For e.g. if  you have to represent rainbow colours with 0 to 6 you can always write them more meaningfully as enum rainbow { RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET }; This […]

As the name signifies, pre-processor directives are instructions given to compiler which it has to run before main code compilation will begin. You must be frequently seeing #include as the top of most C++ program codes. It is nothing but a pre-processor directive to tell compiler that definitions of certain classes, function and objects have […]

Let us begin with understanding of the word polymorphism. The word has a greek origin from words polus/polloi and morphe. ‘Poly’ means ‘many’ and ‘Morph’ means forms. So when any entity has many forms according to its context of use, we may call it polymorphism. This nomenclature is frequently used in biological studies. For e.g. […]

Life is continued journey for one big reason that living beings are able to create new creatures of their own types by passing many attributes of them. This is called Inheritance.   Since Object Oriented Languages boast of modelling the real life and real problems, so they need to implement this feature called inheritance. Infacts […]

Salient Features: SIMPLE AS BASIC: Python is a sort of modern day BASIC language. BEGINNER TO ADVANCED: It is right for beginners and it is truly all purpose in modern times. Language for console applications, GUI applications, scientific applications and web applications. INTERPRETED: It is an interpreted language. This means that line by line error […]

Copy constructor is often quite confusing even for the geeks. Consider a situation of scores of many participants in a game to be initialized to same values but to be kept at different locations. In this case the moment we initialize score of one participant we would like that other participants are simply created based […]

Exception is a type of runtime error while execution of program which user can possibly handle (catch) and report with a suitable message or take some other planned action.   for e.g. divide by zero (Arithmetic exceptions), array out of bound (ArrayIndexOutOfBoundsException), file not found (FileNotFoundException)   Exception can be handled by using the try […]

Concept Learning Code Sheets
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

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.

Function polymorphism/overloading based on parameter count #2258 

Writing polymorphic function based on difference on number of parameters.

Function polymorphism/overloading based on parameter data type #2263 

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.

Function overloading for handling different data types #4479 

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

Function overloading for different number of parameters #4481 

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

#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.

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.

Solved Problems
Displaying multiple String Literals #1563 

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.

Write a C++ code to display the following text "I am happy today." using four separate str ...
Linear search function for search term presence and location #1632 

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.

Write a function linsearch(int [],int, int) which searches for the term 23 in the given in ...
Increment, Decrement Composite Operators Problem 1 #1756 

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 ;
}
Show the output of the following program. Assume that required header files are present. ...
Finding Identifiers and Literals #1778 

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;
}
Write down identifiers and literals in the code given here.  
int main()
{
 ...		
Checking for valid Identifiers #1782 

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;

Find the valid and invalid identifiers in the following piece of code segment.
int a ...		
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 print the list of all natural numbers up to that number. Also print the sum of the natural number printed.

Write a c++ program to collect a positive integer value from the user and print the list o ...
Leap year finding #2008 

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.

Write a c++ program to take the value of a four digit year from the user and then print wh ...
Even odd test #2012 

Write a c++ program to test if the user given integer value is an even number or an odd number.

Write a c++ program to test if the user given integer value is an even number or an odd nu ...
Output writing – If-else with post/pre increment #2014 

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;
}
Write the output of the following c++ program when the user input value are -1 and 1.
Print all divisors and count of divisors #2016 

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

Write a c++ program to ask an integer number from the user and then print all its divisors ...
Output writing – double increment in loop #2031 

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;
}
Write the output of the following code. Assume that required header files are included. < ...
Printable ascii codes #2045 

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.

Write a c++ program to print ascii codes and given printable characters from decimal ascii ...
Secret code with alphabet divisible by five #2047 

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.

Instead of sending his secret code a programmer tells his friend that my secret code is a ...
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 range where range begin variable is initialised in the variable ‘from’ and range end variable is initialised in the variable ‘to’.

Write a c++ program to output the square and square roots of a number in a range where ran ...
Powering a number using a loop #2053 

Write a c++ program to power a base number with the given exponent by using a for loop.

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 are included.

int main()
{
  for(int i=1;i<=30;++i)
  {
    if(i%2==0 || i%3==0) continue;
    else cout<<i<<" ";
  }
  return 0 ;
}
Write the output of the following program. Assume that required header files are included. ...
Print next alphabet if possible #2157 

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.

Write a c++ program to collect an alphabet from the user and then print the next 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 function ispunct() for finding punctuation and use get() function of cin method to collect the user given text matter in a loop.

Write a program to find punctuation in the user given text data. Use the function ispunct( ...
Count punctuation in user given text stream (using getline) #2173 

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.

Write a program to find punctuation in the user given text data. Use the function ispunct( ...
Repeating a character using loop #2218 

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.

Write a program to repeat the character as given by the user for number of times as desire ...
Product of single 2D matrix members #2229 

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.

Write a program to find the product of all members of any 2D Matrix whose size and data me ...
Print formatting using \t and \n escape sequences #2303 

Write the following text using the cout chain using \t and \n escape sequences.

Subjects        Marks
---------------------
Computers       100
Physics         95
Mathematics     98
Write the following text using the cout chain using \t and \n escape sequences.
Sub ...		
Converting input char to int and print ascii #2307 

Write a c++ program to collect a single character from the user and print ascii code of the same character and its next character.

Write a c++ program to collect a single character from the user and print ascii code of t ...
Assignment, equality comparison problem #2314 

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 ;
}
Find the output of the program given below. Assume all relevant header files are included ...
Output of a ternary operator operation #2321 

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;
}
Write output of the following program using the ternary operation logic.
#include &l ...		
Search in 2D Array #2325 

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.

Write a program to search the presence of user given input number in a 2 dimensional arra ...
Average of three integer numbers, double output #2331 

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.

Write a C++ program to find average of three integer numbers given by the user. The output ...
Identify errors in fractional constants #2336 

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

In the following representation of fractional constants, some of them may contain errors i ...
Identify errors in the variable names #2342 

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)

Identify errors in the following variable names and suggest the best alternative name(s) ...
Output writing – loop with unary operators in cout chain #2346 

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;
}

Solve the following program to show its output. Assume that required header files are incl ...
Switch case with fall through example. #2371 

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 ;
}
Write the output of the following code based on the switch-case selection when the user in ...
Simple interest program with function. #2386 

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.

Write a c++ program to define a function si(p,r,t) with input parameters as p, r and t for ...
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 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.

Assume that first two terms of a series are 10 and 11. Then use the Fibonacci series rule ...
Cube series #2420 

Write a program to print the following series up to 15 terms ..
1 8 27 64 125 …….

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 13 19 26 …….

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. Also print the series terms.
x + x^2/2 + x^3/3 + …+x^n/n

Write a program to find the sum of the following series if x is 3 and n is 5. Also print ...
Printing and summing series 1/n! form. #2443 

Write a program to find the sum of the following series upto 5 terms. Also print the series terms.
1/1! + 2/2! + …

Write a program to find the sum of the following series upto 5 terms. Also print the serie ...
Average of temperature values stored in array #2487 

Write a program to store 10 temperature readings in an array and then find the average temperature of the given readings.

Write a program to store 10 temperature readings in an array and then find the average tem ...
Comparing two names for sort order #2577 

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.

Write a program using the strcmp() function to prove that the name RAKESH will come befor ...
count number of spaces in a given sentence #2614 

Write a program  to count the number of space characters in a given input string or sentence using the character match for space character ‘ ‘.

Write a program  to count the number of space characters in a given input string or sente ...
Change case of string input #2625 

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.

Write a program to get input of a string from the user as a character array and then print ...
Removing vowels from string #2628 

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.

Write a program to collect input sentence from user into a character array as a null termi ...
Word count assuming well formed sentence #2632 

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.

Write a program to count words in a given input sentence by a user, assuming that the sent ...
Char array passing to function #2656 

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.

Write a function alpha_count() where a character array is passed as reference and the len ...
Simple Interest function with default parameter values. #2661 

Write output of the following program. Please do take care about the default parameters given while calling the function.

Write output of the following program. Please do take care about the default parameters gi ...
Trailing default parameters check #2666 

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.

A c++ program given here has some errors. Please correct the errors to make it a working p ...
Character replacements in a string #2673 

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.

Write a c++ program to collect a small sentence from the user and then print the same sen ...
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. ...
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 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.

Write a program to count number of words even when there might be extra spaces between wor ...
Correcting error in function call by reference #2742 

Program given below has some incorrectly written function call, correct the mistake and rewrite the
program.

Program given below has some incorrectly written function call, correct the mistake and re ...
Setting bigger of two values using function returning reference #2757 

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.

Write a c++ program using function returning the reference which finds the bigger of two ...
Collect student details to structure and update selectively #2781 

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

Write a program to collect follow entry about an student in a structure type c++ data stru ...
Ternary operator within cout chain for selective printing #2791 

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.

Initialise a character variable. Now using the ternary operator within the cout chain of  ...
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 from the user. Find if the character entered by the user is present in the given sentence or not.

Write a program to get a sentence from the user and then a single character from the user. ...
Proving palindrome array #2848 

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.

Write a program to prove that the give array [23,43,51,43,23] is a palindrome array, means ...
Triangular Number series using the Flyod’s triangle method #2860 

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 ……

Write a program to print a series of triangular numbers starting 1 using the property of a ...
Largest of three numbers using if else ladder #2946 

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.

Write a c++ program to find the largest of three numbers using the if-else selection ladde ...
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 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.

Write a function to return the largest of three integer numbers passed to it as value. A ...
Finding errors in structure declaration #2961 
Find the errors in the following structure declaration.

struct Computer {
 char type[40]="Laptop";
 char p;
 Computer comp;
 float price; 
};c1[20]
Find the errors in the following structure declaration.

struct Computer {
 char t ...		
Output writing using strcpy for structure string variables #2964 

Write the output of the following program. Assume that required header files are present.

struct Game {
  char Magic[20];int Score;
};

int main()
{
  Game M={"Tiger",500};
  char a[20];
  cout<<M.Magic<<", "<<M.Score<<endl;
  strcpy(a,M.Magic);
  a[0]='L'; a[2]='o'; a[3]='n'; a[4]='';
  strcpy(M.Magic,a);
  M.Score++;
  cout<<M.Magic<<", "<<M.Score<<endl;
  return 0;
}
Write the output of the following program. Assume that required header files are present. ...
Slope of line -using structure Point passed to a function #2973 

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.

Write a program by declaring a structure Point with two integer values for its position ...
Output Writing Structure pass by value/reference #2984 

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;
}
Write the output of the following program depicting structure instances being called as va ...
Output Writing – Pixel structure passed by reference #2987 

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 down the output of the program and give steps in arriving at such output.
stru ...		
Function overloading for area functions #2990 

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.

Write a c++ program using function overloading using the following prototype - int area( ...
Error checking switch-case (char-int check) #2994 

Following program may compile and link well but still it may not serve the desired purpose. Find the error.

Following program may compile and link well but still it may not serve the desired purpose ...
Finding Errors #2997 

Find errors in the following program and write the program with correct syntax.

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 –
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.

Write a c++ program using a function with the following prototype - void first_l ...
Displaying long cout chains #3060 

Write a C++ code to display the following text using the same cout chain.
Apples = 5 Kg
Bananas = 2 Doz
Oranges = 2.5 Kg

 

 

Write a C++ code to display the following text using the same cout chain. Apples = 5 Kg ...
gallons to cubic centimeters unit conversion #3066 

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.

Convert given user input in gallons to cubic centimeter.  fter conversion use the conver ...
multiples of an integer #3070 

Write a program to display 2nd, 4th and 6th multiple of the input integer number.

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 sentence by reversing each word in the sentence.

Write a program to take a sentence input from the user and then print the sentence by reve ...
Test palindrome for an integer number #3082 

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.

Write a program where a function of prototype int ispalin(int) is written, which returns 1 ...
function to reverse an integer #3086 

Write a program to reverse the given integer number.using a separately called function to reverse the number.

Write a program to reverse the given integer number.using a separately called function to ...
Sum of integer array #3088 

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.

Write a program to collect 5 integer values from user in an integer array and then pass t ...
Average value of array and members more than average #3098 

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.

Prepare an array of temperature readings of an entire week with data as 25.3, 27.0, 24.8 ...
Square or cube based on even check selection #3122 

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.

Write a program which collects an integer number from the user and if the number is even ...
Finding Errors – Escape Sequences #3164 

There are some errors in the following code due which the expected output as given below will not come
“C++” is tricky & powerful

 

There are some errors in the following code due which the expected output as given below w ...
Finding input variables errors #3190 

Find error in the following program and suggest corrections. Assume that includes and namespace is already given.

Find error in the following program and suggest corrections. Assume that includes and name ...
Output writing implicit typecasting #3208 

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;
}
Write output of the following program if the input given is R
int main()
{
  char  ...		
Output Writing – Logical Operators #3215 

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 ;
}
Write the output of the following program and explain.
int main( )
{
int a=1,b=0;
 ...		
Suggesting Error Corrections in Natural Number Addition #3221 

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.

A student has written this program to sum natural numbers from 1 to 10. His program is n ...
Frequency of a given character in a sentence #3243 

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.

Write a program to input a small sentence from the user and ask about frequency of which  ...
Output writing – If-else ambiguities #3249 

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;
}
Write output of the following code. Assume that required header files are included.
 ...		
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 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.

Write a C++ program to collect a positive integer from the user and the check its reversed ...
Identifying keywords and user defined identifiers #3990 

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

Write the type of C++ tokens (keywords and user defined identifiers) from the following: ...
problem based on setw, setf and unsetf #4321 

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

 

print the following table of temperature record of a patient properly using setw,setf,uns ...
Token Identification #4431 

Identify the type of token (literal, identifier, keyword, punctuator etc.) in the following
1) Case    2) { }    3) break      4) O17

Identify the type of token (literal, identifier, keyword, punctuator etc.) in the followin ...
Marking header files #4445 

Mark the name of required C++ header files for each of the following functions
strlen
getline
exit(0)
tolowerfloor

 

Mark the name of required C++ header files for each of the following functions strlen ge ...
Error finding in function and related code #4447 

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;
}

Find syntactical errors in the following program and rewrite the program after underlining ...
Function overloading – Inch to centimeter conversion #4483 

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.

Write two overloaded functions as follows: Function 1: Convert integer input parameter ...
Swapping first and last row #5000 

Write a user-defined function swap_row(int ARR[ ][3],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

Write a user-defined function swap_row(int ARR[ ][3],int R,int C) in C++ to swap the firs ...
Swapping first and last column #5004 

Write a user-defined function swap_col(int ARR[ ][3],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

Write a user-defined function swap_col(int ARR[ ][3],int R,int C) in C++ to swap the firs ...
Tee Shirts Selection By Sports Teacher #5011 

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.

A sports teacher has been confidentially asked to reject the persons whose Tee-shirt numb ...
Count alphabets in a file #5026 

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

Write a program to count alphabets in a given file "NOTES.TXT". What would be  the outpu ...
Finding student division using a function #5032 

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.

Write a function named DIVISION to pass maximum marks and marks obtained by a student. Re ...
Count Words in a Text File #5034 

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

Write a function to count and return the number of words present in the filename passed to ...
Count Spaces in a Text File #5036 

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

Write a function to count and return the number of space characters present in the filenam ...
Displaying and counting lines starting with a certain character #5039 

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.

Write a program to display the lines starting with character 'A' or 'a' in the file "PROG. ...
Displaying three character words in a file #5044 

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

Write a program to display all the words in a file that are three character words. Assume ...
Required header files in a file handling program #5046 

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;
}
Raju is trying to run the following program in his compiler, but he is unable to do the so ...
Output Writing Based on char and int array reference #5051 

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;
}
Write output of the following code. Assume that all relevant header files have been added. ...
Output Writing – Modifying and Reading int array using a pointer variable #5054 

Write output of the following code.

int main()
{
  int *striker, track[] = {10,20,30,40};
  striker=track;
  track[1]+=30;
  cout<<"striker"<<*striker<<endl;
  *striker-=10;
  striker++;
  cout<<"Next@"<<*striker<<endl;
  striker+=2;
  cout<<"Last@"<<*striker<<endl;
  cout<<"Rest to"<<track[0]<<endl;
  return 0;
}
Write output of the following code.
int main()
{
  int *striker, track[] = {10,20, ...		
Code error in class #5179 

Find error (if any) in the following class definition.

Class PLAY
{
  int number_of_actors=5;
  void set_actor_count()
  {
    number_of_actors=10;
  }
};
Find error (if any) in the following class definition.
Class PLAY
{
  int number ...		
Alphabet series #5182 

Write a program to print the following alphabet series up to 7 terms.

C F I L …..

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 files are included.

int main()
{
  x=1;
  for(int j=10; j>5; j--) 
  cout>>x;
  return 0;
}
Identify errors in the following program. assume that appropriate header files are include ...
File and string related header files #5191 

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;
}
The following C++ code during compilation reports errors as follows: Error: ‘ofstream ...
Error finding, typedef and others #5195 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
Output writing – Function – pass by reference #5197 

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;
}
Find and write the output of the following C++ program code: Note : Assume all required he ...
Output writing – Pointer to array #5204 

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++;
  }
}

 

Find and write the output of the following C++ program code: Note : Assume all required h ...
Output writing – Possible Random Numbers #5224 

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[4], 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@

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
Function overloading identification #5231 

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

Which function(s) out of the following can be considered as overloaded function(s) in the ...
Inherited Function Calling #5235 

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.

Observe the following C++ code and answer the questions (i) and (ii). Note : Assume all n ...
Writing Class Definition #5261 

Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Radius,Height // float
– 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
Type 1 – 3.14*Radius*Height
Type 2 – 2 3.14*Radius*Height/3

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

Write the definition of a class CONTAINER in C++ with the following description: Private ...
Output Writing – Function Returning reference #5265 

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;
}
Write output of the following code. Assume inclusion of related header files.
int &a ...		
Class Inheritance, Member Access and Constructor #5267 

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

class Teacher
{
  int TCode;
  protected:
  char Name[20];
  public:
  Teacher();
  void Enter(); void Show();
};
class Course
{
  int ID;
  protected:
  Char Title[30];
  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?

 

Answer the questions (i) to (iv) based on the following:
class Teacher
{
  int TCo ...		
Sum of even and odd values in an array #5270 

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)

Write the definition of a function SumEO(int VALUES[], int N) in C++, which should displa ...
Printing Top Left Diagonal Half of Square Matrix Including Diagonal Members. #5274 

Write definition for a function UpperHalf(int Mat[4][4]) 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
Write definition for a function UpperHalf(int Mat[4][4]) in C++, which displays the eleme ...
2-D Array Element Address Calculation #5281 

Let us assume Data[20][15] 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[10][5], if the element Data[15][10] is stored at the memory location 15000.

Let us assume Data[20][15] is a two dimensional array, which is stored in the memory alon ...
Identifier or keyword writing #5297 

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

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

Write the type of C++ tokens (keywords and user defined identifiers) from the following: ...
Required header files #5300 

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;
}
Anil typed the following C++ code and during compilation he found three errors as follows ...
Code error finding #5302 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
Macro definition for array filling #5304 

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)<<'#';
  }
}

 

Find and write the output of the following C++ program code: Note: Assume all required he ...
Output writing with pointer based traversing of an array #5318 

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]<<"*";
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
Random Number Based Guessing of output of a 2D Array printing #5322 

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[3][3] = {{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

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
Finding hypotenuse of a right angled triangle #5328 

Write a program to print hypotenuse of a right angled triangle if base and height of the triangle is given by the user.

Write a program to print hypotenuse of a right angled triangle if base and height of the ...
comparing ceil, floor, round, abs function values #5330 

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)

Which of the following math function will return the lowest number as output. Also write ...
Finding errors – Programming basics #5340 

Find errors in the following code and explain. Assume that required header files are present.

main()
{
  cout<<endl<<a;
  return 0;
}
Find errors in the following code and explain. Assume that required header files are prese ...
Correct Identifiers #5343 

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

Only 4 out of 10 names written below can be used as variable names or identifiers by a C+ ...
Output writing – forming expression within cout #5345 

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 ;
}
Write output of the following code. Assume that related header files are included.
i ...		
Addition of Series of Numbers Increasing by 10 #5350 

Write a program to find the sum of following series with any looping statement
12 + 22 + 32 ……… +72

Write a program to find the sum of following series with any looping statement 12 + 22 + ...
Evaluating expressions #5358 

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;
What will be the value of c after evaluating the given expressions on the left side for fo ...
Output writing – Three for loops #5362 

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;
}
Write the output of the following code. Assume all header files are included.
int ma ...		
Code Error Finding #5368 

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<<" ";
}
Rewrite the following program after removing possible compiler errors. Mark each correctio ...
Collecting 2D Array members, Doubling and Printing #5372 

Write a program to collect members of a 2-D integer array in A[3][3] form. Double value of each member and then print the array in matrix form

Write a program to collect members of a 2-D integer array in A[3][3] form. Double value of ...
Finding Valid Multiple value assignments #5573 

Which of the following statements is/are valid and why.
int x;

(i)  x=1,024;

(ii) x=(1,024);

 

Which of the following statements is/are valid and why. int x; (i)  x=1,024; (ii) ...
Output writing – Possible Random Numbers Series #5591 

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:

Go through the C++ code below and find out the possible outputs from the suggested options ...
Output Writing – Three dimensions in structure passed by reference #5596 

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;
}


Write down the output of the program.
struct three_d{int x,y,z;};

void movein(t ...		
Finding incorrect identifiers #5600 

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

Out of the following, find those identifiers, which can not be used for naming Variable, C ...
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;
}
Ronica Jose has started learning C++ and has typed the following program. When she compil ...
Finding and removing Syntax Errors #5610 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correct ...
01D #5614 

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[80];
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;
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
Output writing parameterized class methods #5619 

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();
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
Random picking from string array #5621 

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[][5]={"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
Look at the following C++ code and find the possible output(s) from the options (i) to (iv ...
Characteristics of OOP #5629 

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

Write any four important characteristics of Object Oriented Programming? Give example of ...
OOPs Concept Identification and Destructor Calling Identification #5632 

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

class BOOK
{
  long Code ;
  char Title[20];
  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
  {
    cout<<”Book Discarded!”<<end1;
  }
};
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!”

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessar ...
Defining Class Based on Data Members and Functions Given #5634 

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

Write the definition of a class CITY in C++ with following description: Private Members ...
Inheritance Type, Data and Function Accessibility Identification #5638 

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

class ITEM
{
  int Id;
  char IName[20];
protected:
  float Qty;
public:
  ITEM();
  void Enter(); void View();
};
class TRADER
{
  int DCode;
protected:
  char Manager[20];
public:
  TRADER();
  void Enter();
  void View();
};
class SALEPOINT : public ITEM,private TRADER
{
  char Name[20],Location[20];
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?

Answer the questions (i) to (iv) based on the following:
class ITEM
{
  int Id;
  ...		
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 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

Write a program to search members of integer array 1 in array 2 and print the members of a ...
03A #5652 

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
Write the definition of a function FixSalary(float Salary[], int N) in C++, which should ...
Finding relative address in 2D Array #5661 

R[10][50] 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[5][15], if the element R[8][10] is stored at the memory location 45000.

R[10][50] is a two dimensional array, which is stored in the memory along the row with eac ...
03C #5665 

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[20];
  PRODUCT *Next;
};
class QUEUE
{
  PRODUCT *R,*F;
public:
  QUEUE(){R=NULL;F=NULL;}
  void INSERT();
  void DELETE();
  ~QUEUE();
};
Write the definition of a member function DELETE() for a class QUEUE in C++, to remove a ...
Function to display middle column of 2D Array #5668 

Write definition for a function DISPMID(int A[][5],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

Write definition for a function DISPMID(int A[][5],int R,int C) in C++ to display the elem ...
03E #5674 

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

P/(QR)*S+T

Convert the following Infix expression to its equivalent Postfix expression, showing the s ...
04A #5681 

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
Write function definition for DISP3CHAR() in C++ to read the content of a text file KIDINM ...
04B #5686 

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[20],Status[20]; 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; }
};
Write a definition for function ONOFFER( ) in C++ to read each object of a binary file TO ...
Binary file position determinations using tellg() #5689 

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[20];
  public:
  void Register();void Display();
};
void main()
{
  fstream CFile;
  CFile.open(“CLIENT.DAT”,ios::binary|ios::in);
  CLIENT C;
  CFile.read((char*)&C, sizeof(C));
  cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
  CFile.read((char*)&C, sizeof(C));
  CFile.read((char*)&C, sizeof(C));
  cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
  CFile.close();
}
Find the output of the following C++ code considering that the binary file CLIENT.DAT exi ...
03D #5714 

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;
  char Address[20];
  Packet *LINK;
};
class QUEUE
{
  Packet *Front, *Rear;
public:
  QUEUE(){Front=NULL;Rear=NULL;}
  void AddPacket();
  void DeletePacket();
  ~QUEUE();
};
Write the definition of a member function AddPacket() for a class QUEUE in C++, to remove/ ...
03E #5717 

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

Convert the following Infix expression to its equivalent Postfix expression, showing the s ...
04A #5722 

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#

A text file named MATTER.TXT contains some text, which needs to be displayed such that ev ...
04B #5726 

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[20]; // School Name
  int NOT; // Number of Teachers in the school
public:
  void Display()
  {cout<<SCode<<"#"<<SName<<"#"<<NOT<<endl;}
  int RNOT(){return NOT;}
};
Write a definition for function TotalTeachers( ) in C++ to read each object of a binary fi ...
04C #5730 

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
1005 Guru Shishya Sadan 195
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));
  SFIN.read((char*)&S, sizeof(S));
  S.Display();
  cout<<"Record :"<<SFIN.tellg()/sizeof(S) + 1<<endl;
  SFIN.close();
}
Find the output of the following C++ code considering that the binary file SCHOOLS.DAT exi ...
02A #5752 

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++.

Differentiate between protected and private members of a class in context of Object Orien ...
OOPs Concept Identification and Writing Object Declaration Statements #5756 

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[20];
  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.

Observe the following C++ code and answer the questions (i) and (ii). Note: Assume all ne ...
02C #5759 

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

Write the definition of a class BOX in C++ with following description: Private Members - ...
Finding Type and Member Accessibility #5762 

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()?

Answer the questions (i) to (iv) based on the following:
class First
{
  int X1;
 ...		
03A #5764 

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.
Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even posi ...
Sum of middle column of 2D Matrix #5769 

Write a definition for a function SUMMIDCOL(int MATRIX[][10],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

Write a definition for a function SUMMIDCOL(int MATRIX[][10],int N,int M) in C++, which f ...
2-D Array Element Address Calculation #5772 

ARR[15][20] 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[5][15], if the element ARR[10][5] is stored at the memory location 35000.

ARR[15][20] is a two-dimensional array, which is stored in the memory along the row with ...
03D #5775 

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
{
  int GCODE;         //Gift Code
  char GDESC[20];    //Gift Description
  GIFT *Link;
};
class STACK
{
  Gift *TOP;
public:
  STACK(){TOP=NULL;}
  void PUSHGIFT();
  void POPGIFT();
  ~STACK();
};
Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a G ...
03E #5777 

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

Convert the following Infix expression to its equivalent Postfix expression, showing the ...
04A #5783 

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.
Polina Raj has used a text editing software to type some text in an article. After saving ...
04B #5788 

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[20];//Photo Type as “PORTRAIT”,”NATURE”
public:
  void ENTER()
  {
    cin>>PCODE;gets(PTYPE);
  }
  void SHOWCASE()
  {
    cout<<PCODE<<":"<<PTYPE<<endl;
  }
  char *GETPTYPE(){return PTYPE;}
};
Write a definition for function COUNTPICS ( ) in C++ to read each object of a binary file ...
04C #5793 

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[20];
public:
  void REGISTER();void DISPLAY();
};
void main()
{
  fstream File;
  File.open("CLIENTS.DAT",ios::binary|ios::in);
  CLIENTS C;
  File.seekg(6*sizeof(C));
  File.read((char*)&C, sizeof(C));
  cout<<"Client Number:"<<File.tellg()/sizeof(C) + 1;
  File.seekg(0,ios::end);
  cout<<" of "<<File.tellg()/sizeof(C)<<endl;
  File.close();
}
Find the output of the following C++ code considering that the binary file CLIENTS.DAT ex ...
01A #5825 

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

Find the correct identifiers out of the following, which can be used for naming variable, ...
Header File Marking #5828 

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[80];
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);
}
Observe the following program very carefully and write the names of those header file(s), ...
01C #5831 

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;
}
Observe the following C++ code very carefully and rewrite it after removing any/all synta ...
Output Writing – passing integers as ref and as def value #5834 

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;
}
Write the output of the following C++ program code: Note: Assume all required header file ...
01E #5837 

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
{
  char Grade;
  int Bonus;
public:
  Calc(){Grade='E' ; Bonus=0;}
  void Down(int G)
  {
  Grade-=G;
  }
  Void Up(int G)
  {
    Grade+=G;
    Bonus++;
  }
  void Show()
  {
    cout<<Grade<<"#"<<Bonus<<end1;
  }
};
void main()
{
  Calc c;
  C.Down(2);
  C.Show();
  C.Up(7);
  C.Show();
  C.Down(2)
  C.Show();
}
Write the output of the following C++ program code: Note: Assume all the required header ...
01F #5840 

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
Study the following program and select the possible output(s)from the option (i) to (iv) ...
Copy Constructor Definition and Example #5844 

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 .

What is a copy constructor? Give a suitable example in C++ to illustrate with its definit ...
02B #5848 

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

class Traveller
{
  long PNR;
  char TName[20];
public :
  Traveller()                  //Function 1
  {cout<<"Ready"<<endl;}
  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 ?

Observe the following C++ code and answer the questions (i) and (ii) :
class Travell ...		
02C #5863 

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
Write the definition of a class PlC in C++ with following description: Private Members < ...
02D #5866 

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

class Exterior
{
  int OrderId;
  char Address[20];
protected:
  float Advance;
  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?

Answer the question (i) to (iv) based on the following:
class Exterior
{
  int Ord ...		
03A #5871 

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[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
55 43 20 16 39 90 83 40 48 25

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

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
5 0 5 0 0 5 0 5 0 5
Write the definition of a function Alter(int A[], int N) in C++, which should change all t ...
2-D Array Element Address Calculation #5873 

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

A two dimensional array P[20] [50] is stored in the memory along the row with each of its ...
03C #5878 

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[20]; char TITLE[80];
  TEXTBOOKS *Link;
};
class STACK
{
  TEXTBOOKS *Top;
public:
  STACK() {Top=NULL;}
  void Push();
  void Pop();
  ~STACK();
};
Write the definition of a member function Pop() in C++, to delete a book from a dynamic s ...
Reversing each column in a 2D Matrix #5881 

Write a function REVCOL (int P[][5], 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
Write a function REVCOL (int P[][5], int N, int M) in C++to display the content of a two ...
03E #5885 

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

Convert the following infix expression to its equivalent postfix expression, showing the s ...
04A #5890 

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
Write function definition for SUCCESS () in C++ to read the content of a text file STORY.T ...
04B #5892 

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
{
  int ID;char GIFT[20]; float Cost;
public :
  void Get()
  {
    cin>>CODE;gets(GIFT);cin>>Cost;
  }
void See()
  {
    cout<<ID<<":"<<GIFT<<":"<<Cost<<endl;
  }
  float GetCost() {return Cost;}.
};
Write a definition for function Economic() in C++ to read each record of a binary file IT ...
Finding position in binary file using tellg() #5895 

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[20];
public :
  void In(); void Out();
};
void main{)
{
  fstream CF;
  CF.open("CLIENTS.DAT",ios:: binary| ios::in) ;
  CLIENTS C;
  CF.read((char*)&C,sizeof(C));
  CF.read((char*)&C,sizeof(C));
  CF.read((char*)&C,sizeof(C));
  int POS=CF.tellg()/sizeof(C);
  cout<<"PRESENT RECORD:"<<POS<<endl;
  CF.close() ;
}
Find the output of the following C++ code considering that the binary file CLIENTS.DAT ex ...
01A-2015 #5928 

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

Find the correct identifiers out of the following, which can be used for naming Variable, ...
Header File Marking #5931 

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[80];
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) ;
}

Observe the following program very carefully and write the name of those header file (s), ...
01C-2015 #5933 

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
  char Alert='N' ;
  cin»MySpeed;
  if MySpeed>MaxSpeed
  Alert='Y' ;
  cout<<Alert<<endline;
}
after removing any/all syntactical errors with each correction underlined. Note: Assume a ...
Output Writing – passing integers as ref and as def value #5935 

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 ;
}
Write the output of the following C++ program code: Note: Assume all required header file ...
01E-2015 #5938 

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();
}
Write the output of the following C++ program code: Note: Assume all required header file ...
01F-2015 #5940 

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
Study the following program and select the possible output(s) from the option (i) to (iv) ...
Copy Constructor Definition and Example #5943 

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.

What is a copy constructor? Give a suitable example in C++ to illustrate with its definit ...
02B-2015 #5945 

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

class Passenger
{
  long PNR;
  char Name [20] ;
public:
  Passenger()                 //Function 1
  { cout<<"Ready"<<endl; }
  
  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 ?

Observe the following C++ code and answer the questions (i) and (ii) :
class Passen ...		
02C-2015 #5947 

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
Write the definition of a class Photo in C++ with following description:
Private Me ...		
02D-2015 #5953 

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

class Interior
{
  int OrderId;
  char Address[20];
protected:
  float Advance;
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?

Answer the questions (i) to (iv) based on the following:
class Interior
{
  int Or ...		
03A-2015 #5957 

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[0] P[1] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9]
100 43 20 56 32 91 80 40 45 21

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

P[0] P[1] P[2] P[3] P[4] P[5] P[6] P[7] P[8] P[9]
10 1 10 1 1 1 10 10 1 1
Write the definition of a function Change(int P[], int N) in C++, which should change all ...
2-D Array Element Address Calculation #5959 

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

A two dimensional array ARR[50][20] is stored in the memory along the row with each of it ...
03C-2015 #5962 

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[20], TITLE[80];
  BOOKS *Link;
};
class STACK
{
  BOOKS *Top;
public:
  STACK()
{Top=NULL;}
  void PUSH();
  void POP();
  ~STACK();
};
Write the definition of a member function PUSH() in C++, to add a new book in a dynamic s ...
Reversing each row of a 2D array #5964 

Write a function REVROW(int P[][5],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

Write a function REVROW(int P[][5],int N, int M) in C++ to display the content of a two di ...
03E-2015 #5967 

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

Convert the following infix expression to its equivalent Postfix expression, showing the ...
04A-2015 #5973 

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
Write function definition for TOWER() in C++ to read the content of a text file WRITEUP.TX ...
04B-2015 #5977 

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[20]; float PRICE;
public:
  void Procure()
  {
    cin>>CODE; gets(ITEM);cin>>PRICE;
  }
  void View()
  {
    cout<<CODE<<":"<<ITEM<<":"<<PRICE<<endl;
  }
  float GetPrice() {return PRICE;}
};
Write a definition for function COSTLY() in C++ to read each record of a binary file GIFTS ...
04C-2015 #5979 

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[20];
public:
  void In();void Out();
};
void main()
{
  fstream MF;
  MF.open("MEMBER.DAT”,ios::binary|ios::in);
  MEMBER M;
  MF.read((char*)&M,sizeof(M));
  MF.read((char*)&M,sizeof(M));
  MF.read((char*)&M,sizeof(M));
  int POSITION=MF.tellg()/sizeof(M);
  cout<<"PRESENT RECORD:"<<POSITION<<endl;
  MF.close();
}
Find the output of the following C++ code considering that the binary file MEMBER.DAT exi ...
01A-2017 #6004 

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

Write the type of C++ tokens (keywords and user defined identifiers) from the following: ...
01B-2017 #6006 

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();
}
Anil typed the following C++ code and during compilation he found four errors as follows: ...
01C-2015 #6008 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
01D #6012 

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;
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
01E #6016 

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]<<"#";
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
01F #6018 

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[3][3] = {{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;
  }
}

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
02A #6022 

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++.

Differentiate between private and public members of a class in context of Object Oriented ...
02B #6025 

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[20];
  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.

Observe the following C++ code and answer the questions (i) and (ii). Note: Assume all ne ...
02C #6027 
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
               // Area as 3.14 * Radius*Radius
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
Write the definition of a class RING in C++ with following description:
Private Memb ...		
02D #6030 

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()?

Answer the questions (i) to (iv) based on the following:
class One
{
  int A1;
pr ...		
03A #6032 

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.

Write the definition of a function Reverse(int Arr[], int N) in C++, which should reverse ...
Sum of middle row of 2D Matrix #6036 

Write definition for a function ADDMIDROW(int MAT[][10],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

Write definition for a function ADDMIDROW(int MAT[][10],int R,int C) in C++, which finds ...
2-D Array Element Address Calculation #6039 

T[25][30] 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[10][15], if the element T[5][10] is stored at the memory location 25000.

T[25][30] is a two dimensional array, which is stored in the memory along the row with eac ...
03D #6041 

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[20];
  Member *Next;
};
class QUEUE
{
  Member *Rear,*Front;
public:
  QUEUE(){Rear=NULL;Front=NULL;}
  void ADDMEM();
  void REMOVEMEM();
  ~QUEUE();
};
Write the definition of a member function ADDMEM() for a class QUEUE in C++, to add a MEM ...
03E #6043 

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

Convert the following Infix expression to its equivalent Postfix expression, showing the ...
04A #6047 

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

Aditi has used a text editing software to type some text. After saving the article as WORD ...
Counting of object containing a particular string match in a binary file #6049 

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[20];
public:
  void GET()
  {
    cin>>TID;gets(DEPT);
  }
  void SHOW()
  {
    cout<<TID<<":"<<DEPT<<endl;
  }
  char *RDEPT(){return DEPT;}
};
Write a definition for function COUNTDEPT( ) in C++ to read each object of a binary file ...
04C #6053 

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[20];
public:
  void Enter();void Display();
};
void main()
{
  fstream InFile;
  InFile.open("BOOK.DAT",ios::binary|ios::in);
BOOK B;
  InFile.seekg(5*sizeof(B));
  InFile.read((char*)&B, sizeof(B));
  cout<<"Book Number:"<<InFile.tellg()/sizeof(B) + 1;
  InFile.seekg(0,ios::end);
  cout<<" of "<<InFile.tellg()/sizeof(B)<<endl;
  InFile.close();
}
Find the output of the following C++ code considering that the binary file BOOK.DAT exist ...
01A-2016 #6074 

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,
Address One, Delete, Number12, do

Out of the following, find those identifiers, which cannot be used for naming Variable, Co ...
01B-2016 #6077 

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;
}
Jayapriya has started learning C++ and has typed the following program. When she compiled ...
01C-2016 #6079 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
01D-2017 #6083 

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[80];
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;
}

 

Find and write the output of the following C++ program code: Note: Assume all required he ...
01E-2016 #6085 

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();
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
01F-2016 #6146 

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[][25]={”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

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
02A-2016 #6154 

Differentiate between Constructor and Destructor functions giving suitable example using a class in C++. When does each of them execute?

Differentiate between Constructor and Destructor functions giving suitable example using a ...
02B-2016 #6158 

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

class FICTION
{
  long FCode;
  char FTitle[20];
  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!”?

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessar ...
02C-2016 #6160 
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
Write the definition of a class METROPOLIS in C++ with following description:
Privat ...		
02D-2016 #6162 

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

class PRODUCT
{
  int Code;
  char Item[20];
protected:
  float Qty;
public:
  PRODUCT();
  void GetIn(); void Show();
};
class WHOLESALER
{
  int WCode;
protected:
  char Manager[20];
public:
  WHOLESALER();
  void Enter();
  void Display();
};
class SHOWROOM : public PRODUCT, private WHOLESALER
{
  char Name[20],City[20];
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?

Answer the questions (i) to (iv) based on the following:
class PRODUCT
{
  int Cod ...		
Value modification function of 1 D array using slab based conditions #6165 

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
Write the definition of a function FixPay(float Pay[], int N) in C++, which should modify ...
Finding relative address in 2D Array #6167 

T[20][50] 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[15][5], if the element T[10][8] is stored at the memory location 52000.

T[20][50] is a two dimensional array, which is stored in the memory along the row with ea ...
03C-2016 #6170 

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[20];
  ITEM *Link;
};
class QUEUE
{
  ITEM *R,*F;
public:
  QUEUE(){R=NULL;F=NULL;}
  void INSERT();
  void DELETE();
  ~QUEUE();
};
Write the definition of a member function INSERT() for a class QUEUE in C++, to insert an ...
Function to show middle row and middle column of a 2D Array #6174 

Write definition for a function SHOWMID(int P[][5],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

Write definition for a function SHOWMID(int P[][5],int R,int C) in C++ to display the ele ...
03E-2016 #6177 

Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion.
A/(B+C)*D-E

Convert the following Infix expression to its equivalent Postfix expression, showing the ...
Finding 4 character words in a text file #6179 

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
Write function definition for WORD4CHAR() in C++ to read the content of a text file FUN.TX ...
Finding data match in binary file #6182 

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
{
  int ID;char Gift[20],Remarks[20]; float Price;
  public:
  void Takeonstock()
  {
    cin>>ID;gets(Gift);gets(Remarks);cin>>Price;
  }
  void See()
  {
    cout<<ID<<":"<<Gift<<":"<<Price<<"":"<<Remarks<<endl;
  }
  char *GetRemarks(){return Remarks;}
};
Write a definition for function BUMPER( ) in C++ to read each object of a binary file GIFT ...
Finding position in binary file using tellg() #6184 

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[20];
public:
  void Register();void Display();
};
void main()
{
  fstream MFile;
  MFile.open("MEM.DAT",ios::binary|ios::in);
  MEMBER M;
  MFile.read((char*)&M, sizeof(M));
  cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl;
  MFile.read((char*)&M, sizeof(M));
  MFile.read((char*)&M, sizeof(M));
  cout<<"Rec:"<<MFile.tellg()/sizeof(M)<<endl;
  MFile.close();
}
Find the output of the following C++ code considering that the binary file MEM.DAT exists ...
01A-2019S #6559 

Write the type of C++ Operators (Arithmetic, Logical, and Relational Operators) from the following:
(i) !(ii) !=(iii) &&(iv) %

Write the type of C++ Operators (Arithmetic, Logical, and Relational Operators) from the f ...
01B-2019S #6562 

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[20], newText[20];
  gets(text);
  strcpy(newText,text);
  for(int i=0;i<strlen(text);i++)
    if(text[i]==’A’)
      text[i]=text[i]+2;
  puts(text);
}
Observe the following program very carefully and write the name of those header file(s), w ...
01C-2019S #6564 

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;
}
Rewrite the following C++ code after removing any/all Syntactical Error(s) with each corre ...
01D-2019S #6567 

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[3] - Ar[2] ;
cout<<++*(Ptr+I)<<'@'<<"\n" ;
cout<<++I + *Ptr++ << '@' ;
cout<<*Ptr++ <<'@'<< '\n' ; for( ; I >=0 ; I -=2)
  cout<<Ar[I] << '@' ;
}
Find and write the output of the following C++ program code: Note: Assume all required hea ...
01E-2019S #6570 

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

typedef char STRING[80];
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;
}
Find and write the output of the following C++ program code:
typedef char STRING[80] ...		
01F-2019S #6572 

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#
Observe the following program and find out, which output(s) out of (i) to (iv) willbe expe ...
02A-2019S #6580 

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 

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

Write the output of the following C++ code. Also, write the name of feature of Object Orie ...
02C-2019S #6589 

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.
Define a class Ele_Bill in C++ with the following descriptions:
Private memb ...		
02D-2019S #6591 

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

class Faculty
{
  int FCode;
protected:
  char FName[20];
public:
  Faculty();
  void Enter();
  void Show();
};
class Programme
{
  int PID;
protected:
  char Title[30];
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()?

Answer the questions (i) to (iv) based on the following:
class Faculty
{
  int FCo ...		
03A-2019S #6595 

Write a user-defined function AddEnd4(int A[][4],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.

Write a user-defined function AddEnd4(int A[][4],int R,int C) in C++ to find and display t ...
03B-2019S #6598 

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

Write a user-defined function EXTRA_ELE(int A[ ], int B[ ], int N) in C++ to find and disp ...
03C-2019S #6601 

An array S[10] [30] is stored in the memory along the column with each of its element occupying 2 bytes. Find out the memory location of S[5][10], if element S[2][15] is stored at the location 8200.

OR

An array A[30][10] 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[12][8], if the content is stored along the row.

 

An array S[10] [30] is stored in the memory along the column with each of its element occu ...
03D-2019S #6604 

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[20];
};
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
};
Write the definition of a member function Ins_Player() for a class CQUEUE in C++, to add a ...
03E-2019S #6607 

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,/,-

Convert the following Infix expression to its equivalent Postfix expression, showing the s ...
04A-2019S #6610 

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”.

Write a function RevText() to read a text file “ Input.txt “ and Print only word start ...
04B-2019S #6612 

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[20]; // Bus Starting Point
  char To[20]; // Bus Destination
public:
  char * StartFrom ( ); { return From; }
  char * EndTo( ); { return To; }
  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[20];
public: void Enter()
{
cin>>Rno;gets(Sname);
}
void show()
{
count << Rno<<sname<<endl;
}
};
Write a function in C++ to search and display details, whose destination is “Cochin” ...
04C-2019S #6615 

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[20];
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));
  In.read((char*)&P, sizeof(P));
  In.read((char*)&P, sizeof(P));
  cout<<"At Product:"<<In.tellg()/sizeof(P) + 1;
  In.close();
}

OR

Which file stream is required for seekg() ?

Find the output of the following C++ code considering that the binary file PRODUCT.DAT ex ...
01A-2018S #6637 

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.

What is the role of a parameter/argument passed in a function? Can a default value be assi ...
01B-2018S #6641 

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()
{
char Grade;
cin.get(Grade);
if(isalpha(Grade))
   cout.put(Grade);
}

Suggested header files:-
1. iostream.h
2. stdio.h
3. conio.h
4. ctype.h

Raman suggests Kishan the following header files which are required to be included in the ...
01C-2018S #6644 

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;
}

Rewrite the following program after removing the syntactical errors (if any). Underline ea ...
01D-2018S #6646 

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;
}
}

 

Write the output of the following C++ program code (assume all necessary header files are ...
01E-2018S #6649 

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–]);
}
}

Write the output of the following C++ program code(assume all necessary header files are i ...
01F-2018S #6652 

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

Consider the following C++ program code and choose the option(s) which are not possible as ...
02A-2018S #6654 

What do you mean by Data Abstraction in OOPs? Explain its significance with a suitable example.

What do you mean by Data Abstraction in OOPs? Explain its significance with a suitable exa ...
02B-2018S #6657 

Answer the question (i) & (ii) after going through the following code. (assume all necessary header files are included in program):-

class Game
{
char Name [21];
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
}

Answer the question (i) & (ii) after going through the following code. (assume all nec ...
02C-2018S #6661 

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.

Define a class Bill in OOP with the following specification:- Private members: 1. Bill_n ...
02D-2018S #6664 
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[30];
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[25];
protected:
  int State_Population;
public:
  State();
  void New_State();
  void Print_State();
};
class Country : private State
{
  int Country_Id;
  char Country_Name[25];
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.

Answer the question from (i) to (iv) based on the given below code
(assume all neces ...		
03A-2018S #6667 

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

Write the definition of function named Array_Swap() that will accept an integer array & ...
03B-2018S #6669 

An array A[50][30] is stored along the row in the memory with each element requiring 4 bytes of storage. If the element A[10][15] is stored at 21500, then find out the base address of the array and the memory address of element stored at location A[30][25]?

An array A[50][30] is stored along the row in the memory with each element requiring 4 byt ...
03C-2018S #6671 

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[21];
  Application *Link;
};
class Exam_Queue
{
  Application *Front, *Rear;
public;
  Exam_Queue()   //Constructor
  {
  Front=Rear=NULL;
  }
  void Q_Insert ();
  void Q_Delete();
};

Write the definition of a member function Q_Insert() for a class Exam_Queue in C++ to inse ...
03D-2018S #6675 

Write the definition of a user-defined function REPEAT_ROW(int A[][3],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:-

5 6 10 2
2 6 9 12
18 14 5 6

Then, the contents of the array after execution of the above function will be:-

5 5 5 5
2 6 6 6
18 14 5 5
Write the definition of a user-defined function REPEAT_ROW(int A[][3],int R, int C) in C++ ...
03E-2018S #6691 

Evaluate the following POSTFIX expression. Show the status of Stack after execution of each operation separately:
TRUE, FALSE, OR, NOT, TRUE, FALSE, AND, OR

Evaluate the following POSTFIX expression. Show the status of Stack after execution of eac ...
04A-2018S #6694 

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[21]; //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())
  {
    File.read((char*)&R, sizeof(R));
    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”.

Answer the questions (i) & (ii) in the program segment given below for the required ta ...
04B-2018S #6696 

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.”

Write a user-defined function named Count() that will read the contents o ...
04C-2018S #6698 

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.

Consider the following class Item:-
class Item
{
  int ItemId;
  int Quantity;
  ...		
01A-2019S #6942 

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 

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];
}
Write the names of the correct header files, which must be included in the following C++ c ...
01C-2019S #6951 

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
{
  int Length, Breadth;
};
  void main()
{
  Recta R= [10, 15];
  cout<<Area(Length.R, Breadth.R);
}
Rewrite the following C++ Program after removing any/all syntactical error(s). Underline e ...
Function arguments as pointer reference – Output writing #6953 

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;
}

 

Find and write the output of the following C++ program code: Note: Assume all required ...
01E-2019S #6959 

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) ;
}
Find and write the output of the following C++ program code: Note: Assume all required ...
01F-2019S #6962 

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$
Observe the following C++ code and find the possible output(s) from the option (i) to ( ...
02A-2019S #6968 

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[201];
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.

Given the following class Test and assuming all necessary header file(s) included, answer ...
02B-2019S-C1 #6970 

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 ?

Observe the following C++ code and answer the questions (i) and (ii). Note: Assume ...
02B-2019S-C2 #6972 

Explain Polymorphism in context of Object Oriented Programming.

Also give a supporting example in C++.

Explain Polymorphism in context of Object Oriented Programming. Also give a supporting ...
02C-2019S #6977 

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
Write the definition of a class GRAPH in C++ with following description: Private Member ...
02D-2019S-C1 #6982 

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.

Answer the questions (i) to (iv) based on the following:
class Ground
{
  int Room ...		
02D-2019S-C2 #6985 

Consider the following class HeadQuarter

class HeadQuarter
{
  int Code;
  char Des[20];
protected:
  char Address[40];
public:
  void Get() {cin>>Code;gets(Des);gets(Address);}
  void Put() {cout<<Code<<Des<<Address<<endl;}
};

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

Consider the following class HeadQuarter
class HeadQuarter
{
  int Code;
  char D ...		
03A-2019S-C1 #6987 

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

Write a user-defined function NoTwoThree(int Arr[], int N) in C++, which should display th ...
03A-2019S-C2 #6992 

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.
Write a user-defined function ReArrange(int Arr[], int N) in C++, which s ...
03B-2019S-C1 #6994 

Write definition for a function XOXO(char M[4][4]) 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.
Write definition for a function XOXO(char M[4][4]) in C++, which replaces every occurrence ...
03B-2019S-C2 #6997 

Write definition for a function ColSwap(int A[4][4]) 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.
Write definition for a function ColSwap(int A[4][4]) in C++, which swaps the contents of t ...
03C-2019S-C1 #7003 

Let us assume P[20][10] 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[10][5], if the address of the element P[5][2] is 25000.

Let us assume P[20][10] is a two-dimensional array, which is stored in the memory along th ...
03C-2019S-C2 #7005 

Let us assume P[20][30] 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[5][6], if the base address of array is 25000.

Let us assume P[20][30] is a two-dimensional array, which is stored in the memory along th ...
03D-2019S-C1 #7007 

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[20];
};
Write a user-defined function Pop(Book B[], int &T), which pops the details of a Book, ...
03D-2019S-C2 #7009 

For the following structure of Books in C++

Struct Book
{
  int   Bno;
  char  Bname[20];
  Book  *Link;
};

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();
};

 

For the following structure of Books in C++
Struct Book
{
  int   Bno;
  char  Bn ...		
03E-2019S-C1 #7011 

Evaluate the following Postfix expression, showing the stack contents:

250,45,9,/,5,+,20,*,-

Evaluate the following Postfix expression, showing the stack contents: 250,45,9 ...
03E-2019S-C2 #7014 

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

 

A + B * C ^ D – E

Convert the following Infix expression to its equivalent Postfix expression , showing  th ...
04A-2019S-C1 #7018 

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.

A text file named MESSAGE.TXT contains some text. Another text file named ...
04A-2019S-C2 #7020 

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

A text file named CONTENTS.TXT contains some text. Write a user-defined function LongWords ...
04B-2019S-C1 #7023 

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[20]; float Price;
public:
char* RName() { return Name; }
float RPrice() { return Price; }
};

Write a user-defined function TotalPrice() in C++ to read each object of a binary file STO ...
04B-2019S-C2 #7026 

A binary file DOCTORS.DAT contains records stored as objects of the following class:

class Doctor
{
  int DNo; char Name[20]; 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.

A binary file DOCTORS.DAT contains records stored as objects of the following class:
      
04C-2019S-C1 #7030 

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.read((char*)&S, sizeof(S));
    cout<<"Read:"<<File.tellg()/sizeof(S)<<endl;
  }
  File.close();
}
Find the output of the following C++ code considering that the binary file STOCK.DAT exist ...
04C-2019S-C2 #7038 

Differentiate between seekg() and tellg().

Differentiate between seekg() and tellg(). ...
Output writing – pointer and pointer value increment for array #7500 

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[3] - Ar[2] ;
  cout<<++*(Ptr+I)<<'@';
  cout<<Ar[I]<<'@';
  return 0;
}
Find and write the output of the following C++ program code.
int main( )
{
  int A ...		
Finding Type and Member Accessibility #7635 

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.

Answer the questions (i) to (iv) based on the following:
class Shape
{
  int lengt ...		
Array of Structure – Output Writing #7663 

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[0].Year<<'#'<<Arr[0].Topper<<endl;
  change(++point);
  cout<<Year<<'#'<<Topper<<endl;
  return 0; 
}


Find and write the output of the following C++ program code: Note: Assume all required he ...
Output writing using structure copy and strcat use #7684 
struct Play {char Arr[20];int n;}; 
int main() 
{ 
  struct Play P={"JUDO",2};
  P.Arr[0]='L';
  P.n+=2; 
  cout<<P.Arr<<"#"<<P.n<<endl;   
  Play R = P;
  R.Arr[0]='S';R.Arr[1]='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.

struct Play {char Arr[20];int n;}; 
int main() 
{ 
  struct Play P={"JUDO",2};
   ...		
Output writing using structure copy and strcat use #7691 
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.

struct Employee{double salary,hra;};
void change(Employee &a,double h=100)
{
  ...		
Output Writing – passing integers as ref and as def value #7699 

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;
}
Write the output of the following C++ program code: Note: Assume all required header file ...
Output writing – Pointer to string elements #7704 

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[2])<<endl;
  cout.write(str,2)<<endl;
  cout.write(str+2,9)<<endl;
  return 0;
}

 

Find and write the output of the following C++ program code: Note : Assume all required h ...
Output writing – Pointer to string as char array #7709 

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;
}

 

Find and write the output of the following C++ program code: Note : Assume all required h ...
Exam Questions
CBSE12A-2018-01B  File and string related header files #5191 

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;
}
The following C++ code during compilation reports errors as follows: Error: ‘ofstream ...
CBSE12A-2018-01C  Error finding, typedef and others #5195 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
CBSE12A-2018-01D  Output writing – Function – pass by reference #5197 

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;
}
Find and write the output of the following C++ program code: Note : Assume all required he ...
CBSE12A-2018-01E  Output writing – Pointer to array #5204 

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++;
  }
}

 

Find and write the output of the following C++ program code: Note : Assume all required h ...
CBSE12A-2018-01F  Output writing – Possible Random Numbers #5224 

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[4], 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@

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
CBSE12A-2018-02A  Function overloading identification #5231 

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

Which function(s) out of the following can be considered as overloaded function(s) in the ...
CBSE12A-2018-02B  Inherited Function Calling #5235 

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.

Observe the following C++ code and answer the questions (i) and (ii). Note : Assume all n ...
CBSE12A-2018-02C  Writing Class Definition #5261 

Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Radius,Height // float
– 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
Type 1 – 3.14*Radius*Height
Type 2 – 2 3.14*Radius*Height/3

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

Write the definition of a class CONTAINER in C++ with the following description: Private ...
CBSE12A-2018-02D  Class Inheritance, Member Access and Constructor #5267 

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

class Teacher
{
  int TCode;
  protected:
  char Name[20];
  public:
  Teacher();
  void Enter(); void Show();
};
class Course
{
  int ID;
  protected:
  Char Title[30];
  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?

 

Answer the questions (i) to (iv) based on the following:
class Teacher
{
  int TCo ...		
CBSE12A-2018-03A  Sum of even and odd values in an array #5270 

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)

Write the definition of a function SumEO(int VALUES[], int N) in C++, which should displa ...
CBSE12A-2018-03B  Printing Top Left Diagonal Half of Square Matrix Including Diagonal Members. #5274 

Write definition for a function UpperHalf(int Mat[4][4]) 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
Write definition for a function UpperHalf(int Mat[4][4]) in C++, which displays the eleme ...
CBSE12A-2018-03C  2-D Array Element Address Calculation #5281 

Let us assume Data[20][15] 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[10][5], if the element Data[15][10] is stored at the memory location 15000.

Let us assume Data[20][15] is a two dimensional array, which is stored in the memory alon ...
CBSE12A-2017-01A  Identifier or keyword writing #5297 

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

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

Write the type of C++ tokens (keywords and user defined identifiers) from the following: ...
CBSE12A-2017-01B  Required header files #5300 

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;
}
Anil typed the following C++ code and during compilation he found three errors as follows ...
CBSE12A-2017-01C  Code error finding #5302 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correc ...
CBSE12A-2017-01D  Macro definition for array filling #5304 

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)<<'#';
  }
}

 

Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12A-2017-01E  Output writing with pointer based traversing of an array #5318 

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]<<"*";
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12A-2017-01F  Random Number Based Guessing of output of a 2D Array printing #5322 

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[3][3] = {{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

Look at the following C++ code and find the possible output(s) from the options (i) to (i ...
CBSE12A-2016-01A  Finding incorrect identifiers #5600 

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

Out of the following, find those identifiers, which can not be used for naming Variable, C ...
CBSE12A-2016-01B  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;
}
Ronica Jose has started learning C++ and has typed the following program. When she compil ...
CBSE12A-2016-01C  Finding and removing Syntax Errors #5610 

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;
}
Rewrite the following C++ code after removing any/all syntactical errors with each correct ...
CBSE12A-2016-01D  01D #5614 

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[80];
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;
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12A-2016-01E  Output writing parameterized class methods #5619 

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();
}
Find and write the output of the following C++ program code: Note: Assume all required he ...
CBSE12A-2016-01F  Random picking from string array #5621 

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[][5]={"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
Look at the following C++ code and find the possible output(s) from the options (i) to (iv ...
CBSE12A-2016-02A  Characteristics of OOP #5629 

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

Write any four important characteristics of Object Oriented Programming? Give example of ...
CBSE12A-2016-02B  OOPs Concept Identification and Destructor Calling Identification #5632 

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

class BOOK
{
  long Code ;
  char Title[20];
  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
  {
    cout<<”Book Discarded!”<<end1;
  }
};
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!”

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessar ...
CBSE12A-2016-02C  Defining Class Based on Data Members and Functions Given #5634 

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

Write the definition of a class CITY in C++ with following description: Private Members ...
CBSE12A-2016-02D  Inheritance Type, Data and Function Accessibility Identification #5638 

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

class ITEM
{
  int Id;
  char IName[20];
protected:
  float Qty;
public:
  ITEM();
  void Enter(); void View();
};
class TRADER
{
  int DCode;
protected:
  char Manager[20];
public:
  TRADER();
  void Enter();
  void View();
};
class SALEPOINT : public ITEM,private TRADER
{
  char Name[20],Location[20];
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?

Answer the questions (i) to (iv) based on the following:
class ITEM
{
  int Id;
  ...		
CBSE12A-2016-03A  03A #5652 

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
Write the definition of a function FixSalary(float Salary[], int N) in C++, which should ...
CBSE12A-2016-03B  Finding relative address in 2D Array #5661 

R[10][50] 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[5][15], if the element R[8][10] is stored at the memory location 45000.

R[10][50] is a two dimensional array, which is stored in the memory along the row with eac ...
CBSE12A-2016-03C  03C #5665 

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[20];
  PRODUCT *Next;
};
class QUEUE
{
  PRODUCT *R,*F;
public:
  QUEUE(){R=NULL;F=NULL;}
  void INSERT();
  void DELETE();
  ~QUEUE();
};
Write the definition of a member function DELETE() for a class QUEUE in C++, to remove a ...
CBSE12A-2016-03D  Function to display middle column of 2D Array #5668 

Write definition for a function DISPMID(int A[][5],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

Write definition for a function DISPMID(int A[][5],int R,int C) in C++ to display the elem ...
CBSE12A-2016-03E  03E #5674 

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

P/(QR)*S+T

Convert the following Infix expression to its equivalent Postfix expression, showing the s ...
CBSE12A-2016-04A  04A #5681 

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
Write function definition for DISP3CHAR() in C++ to read the content of a text file KIDINM ...
CBSE12A-2016-04B  04B #5686 

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[20],Status[20]; 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; }
};
Write a definition for function ONOFFER( ) in C++ to read each object of a binary file TO ...
CBSE12A-2016-04C  Binary file position determinations using tellg() #5689 

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[20];
  public:
  void Register();void Display();
};
void main()
{
  fstream CFile;
  CFile.open(“CLIENT.DAT”,ios::binary|ios::in);
  CLIENT C;
  CFile.read((char*)&C, sizeof(C));
  cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
  CFile.read((char*)&C, sizeof(C));
  CFile.read((char*)&C, sizeof(C));
  cout<<”Rec:”<<CFile.tellg()/sizeof(C)<<endl;
  CFile.close();
}
Find the output of the following C++ code considering that the binary file CLIENT.DAT exi ...
CBSE12A-2018-03D  03D #5714 

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;
  char Address[20];
  Packet *LINK;
};
class QUEUE
{
  Packet *Front, *Rear;
public:
  QUEUE(){Front=NULL;Rear=NULL;}
  void AddPacket();
  void DeletePacket();
  ~QUEUE();
};
Write the definition of a member function AddPacket() for a class QUEUE in C++, to remove/ ...
CBSE12A-2018-03E  03E #5717 

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

Convert the following Infix expression to its equivalent Postfix expression, showing the s ...
CBSE12A-2018-04A  04A #5722 

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#

A text file named MATTER.TXT contains some text, which needs to be displayed such that ev ...
CBSE12A-2018-04B  04B #5726 

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[20]; // School Name
  int NOT; // Number of Teachers in the school
public:
  void Display()
  {cout<<SCode<<"#"<<SName<<"#"<<NOT<<endl;}
  int RNOT(){return NOT;}
};
Write a definition for function TotalTeachers( ) in C++ to read each object of a binary fi ...
CBSE12A-2018-04C  04C #5730 

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
1005 Guru Shishya Sadan 195
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));
  SFIN.read((char*)&S, sizeof(S));
  S.Display();
  cout<<"Record :"<<SFIN.tellg()/sizeof(S) + 1<<endl;
  SFIN.close();
}
Find the output of the following C++ code considering that the binary file SCHOOLS.DAT exi ...
CBSE12A-2017-02A  02A #5752 

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++.

Differentiate between protected and private members of a class in context of Object Orien ...
CBSE12A-2017-02B  OOPs Concept Identification and Writing Object Declaration Statements #5756 

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[20];
  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.

Observe the following C++ code and answer the questions (i) and (ii). Note: Assume all ne ...
CBSE12A-2017-02C  02C #5759 

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

Write the definition of a class BOX in C++ with following description: Private Members - ...
CBSE12A-2017-02D  Finding Type and Member Accessibility #5762 

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()?

Answer the questions (i) to (iv) based on the following:
class First
{
  int X1;
 ...		
CBSE12A-2017-03A  03A #5764 

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.
Write the definition of a function AddUp(int Arr[], int N) in C++, in which all even posi ...
CBSE12A-2017-03B  Sum of middle column of 2D Matrix #5769 

Write a definition for a function SUMMIDCOL(int MATRIX[][10],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

Write a definition for a function SUMMIDCOL(int MATRIX[][10],int N,int M) in C++, which f ...
CBSE12A-2017-03C  2-D Array Element Address Calculation #5772 

ARR[15][20] 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[5][15], if the element ARR[10][5] is stored at the memory location 35000.

ARR[15][20] is a two-dimensional array, which is stored in the memory along the row with ...
CBSE12A-2017-03D  03D #5775 

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
{
  int GCODE;         //Gift Code
  char GDESC[20];    //Gift Description
  GIFT *Link;
};
class STACK
{
  Gift *TOP;
public:
  STACK(){TOP=NULL;}
  void PUSHGIFT();
  void POPGIFT();
  ~STACK();
};
Write the definition of a member function PUSHGIFT() for a class STACK in C++, to add a G ...
CBSE12A-2017-03E  03E #5777 

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

Convert the following Infix expression to its equivalent Postfix expression, showing the ...
CBSE12A-2017-04A  04A #5783 

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.
Polina Raj has used a text editing software to type some text in an article. After saving ...
CBSE12A-2017-04B  04B #5788 

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[20];//Photo Type as “PORTRAIT”,”NATURE”
public:
  void ENTER()
  {
    cin>>PCODE;gets(PTYPE);
  }
  void SHOWCASE()
  {
    cout<<PCODE<<":"<<PTYPE<<endl;
  }
  char *GETPTYPE(){return PTYPE;}
};
Write a definition for function COUNTPICS ( ) in C++ to read each object of a binary file ...
CBSE12A-2017-04C  04C #5793 

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[20];
public:
  void REGISTER();void DISPLAY();
};
void main()
{
  fstream File;
  File.open("CLIENTS.DAT",ios::binary|ios::in);
  CLIENTS C;
  File.seekg(6*sizeof(C));
  File.read((char*)&C, sizeof(C));
  cout<<"Client Number:"<<File.tellg()/sizeof(C) + 1;
  File.seekg(0,ios::end);
  cout<<" of "<<File.tellg()/sizeof(C)<<endl;
  File.close();
}
Find the output of the following C++ code considering that the binary file CLIENTS.DAT ex ...
CBSE12D-2015-01A  01A #5825 

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

Find the correct identifiers out of the following, which can be used for naming variable, ...
CBSE12D-2015-01B  Header File Marking #5828 

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[80];
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);
}
Observe the following program very carefully and write the names of those header file(s), ...
CBSE12D-2015-01C  01C #5831 

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;
}
Observe the following C++ code very carefully and rewrite it after removing any/all synta ...
CBSE12D-2015-01D  Output Writing – passing integers as ref and as def value #5834 

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;
}
Write the output of the following C++ program code: Note: Assume all required header file ...
CBSE12D-2015-01E  01E #5837 

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
{
  char Grade;
  int Bonus;
public:
  Calc(){Grade='E' ; Bonus=0;}
  void Down(int G)
  {
  Grade-=G;
  }
  Void Up(int G)
  {
    Grade+=G;
    Bonus++;
  }
  void Show()
  {
    cout<<Grade<<"#"<<Bonus<<end1;
  }
};
void main()
{
  Calc c;
  C.Down(2);
  C.Show();
  C.Up(7);
  C.Show();
  C.Down(2)
  C.Show();
}
Write the output of the following C++ program code: Note: Assume all the required header ...
CBSE12D-2015-01F  01F #5840 

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
Study the following program and select the possible output(s)from the option (i) to (iv) ...
CBSE12D-2015-02A  Copy Constructor Definition and Example #5844 

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 .

What is a copy constructor? Give a suitable example in C++ to illustrate with its definit ...
CBSE12D-2015-02B  02B #5848 

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

class Traveller
{
  long PNR;
  char TName[20];
public :
  Traveller()                  //Function 1
  {cout<<"Ready"<<endl;}
  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 ?

Observe the following C++ code and answer the questions (i) and (ii) :
class Travell ...		
CBSE12D-2015-02C  02C #5863 

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
Write the definition of a class PlC in C++ with following description: Private Members < ...
CBSE12D-2015-02D  02D #5866 

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

class Exterior
{
  int OrderId;
  char Address[20];
protected:
  float Advance;
  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?

Answer the question (i) to (iv) based on the following:
class Exterior
{
  int Ord ...		
CBSE12D-2015-03A  03A #5871 

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[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
55 43 20 16 39 90 83 40 48 25

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

A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]
5 0 5 0 0 5 0 5 0 5
Write the definition of a function Alter(int A[], int N) in C++, which should change all t ...
CBSE12D-2015-03B  2-D Array Element Address Calculation #5873 

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

A two dimensional array P[20] [50] is stored in the memory along the row with each of its ...
CBSE12D-2015-03C  03C #5878 

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[20]; char TITLE[80];
  TEXTBOOKS *Link;
};
class STACK
{
  TEXTBOOKS *Top;
public:
  STACK() {Top=NULL;}
  void Push();
  void Pop();
  ~STACK();
};
Write the definition of a member function Pop() in C++, to delete a book from a dynamic s ...
CBSE12D-2015-03D  Reversing each column in a 2D Matrix #5881 

Write a function REVCOL (int P[][5], 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
Write a function REVCOL (int P[][5], int N, int M) in C++to display the content of a two ...
CBSE12D-2015-03E  03E #5885 

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

Convert the following infix expression to its equivalent postfix expression, showing the s ...
CBSE12D-2015-04A  04A #5890 

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
Write function definition for SUCCESS () in C++ to read the content of a text file STORY.T ...
CBSE12D-2015-04A  04B #5892 

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
{
  int ID;char GIFT[20]; float Cost;
public :
  void Get()
  {
    cin>>CODE;gets(GIFT);cin>>Cost;
  }
void See()
  {
    cout<<ID<<":"<<GIFT<<":"<<Cost<<endl;
  }
  float GetCost() {return Cost;}.
};
Write a definition for function Economic() in C++ to read each record of a binary file IT ...
CBSE12D-2015-04C  Finding position in binary file using tellg() #5895 

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[20];
public :
  void In(); void Out();
};
void main{)
{
  fstream CF;
  CF.open("CLIENTS.DAT",ios:: binary| ios::in) ;
  CLIENTS C;
  CF.read((char*)&C,sizeof(C));
  CF.read((char*)&C,sizeof(C));
  CF.read((char*)&C,sizeof(C));
  int POS=CF.tellg()/sizeof(C);
  cout<<"PRESENT RECORD:"<<POS<<endl;
  CF.close() ;
}
Find the output of the following C++ code considering that the binary file CLIENTS.DAT ex ...
CBSE12A-2015-01A  01A-2015 #5928 

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

Find the correct identifiers out of the following, which can be used for naming Variable, ...
CBSE12A-2015-01B  Header File Marking #5931 

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[80];
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) ;
}

Observe the following program very carefully and write the name of those header file (s), ...
CBSE12A-2015-01C  01C-2015 #5933 

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
  char Alert='N' ;
  cin»MySpeed;
  if MySpeed>MaxSpeed
  Alert='Y' ;
  cout<<Alert<<endline;
}
after removing any/all syntactical errors with each correction underlined. Note: Assume a ...