0% found this document useful (0 votes)
285 views5 pages

Kendriya Vidyalaya Fortwilliam Class Xii Cs Monthly Test August Out o

1. The identifiers that cannot be used for naming variables, constants or functions in C++ are: float, Switch, Delete 2. The header files required to be included for the code are: <iostream> and <math.h> 3. The corrected C++ code after removing syntactical errors is: #define Equation(p,q) p+2*q void main() { float A=3.2, B=4.1; C=Equation(A,B); cout<<"Output="<<C<<endl; }

Uploaded by

Namita Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
285 views5 pages

Kendriya Vidyalaya Fortwilliam Class Xii Cs Monthly Test August Out o

1. The identifiers that cannot be used for naming variables, constants or functions in C++ are: float, Switch, Delete 2. The header files required to be included for the code are: <iostream> and <math.h> 3. The corrected C++ code after removing syntactical errors is: #define Equation(p,q) p+2*q void main() { float A=3.2, B=4.1; C=Equation(A,B); cout<<"Output="<<C<<endl; }

Uploaded by

Namita Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

KENDRIYA VIDYALAYA FORTWILLIAM CLASS XII CS MONTHLY TEST AUGUST

1. Out of the following, find those identifiers, which cannot be used for naming Variable, Constants or Functions in a
C++ program : 2
_Cost, Price*Qty, float, Switch,Address One, Delete, Number12, do
2. 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. 1
void main()
{
float A,Number,Outcome;
cin>>A>>Number;
Outcome=pow(A,Number);
cout<<Outcome<<endl;
}
3. Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined. 2
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;
}
4. Find and write the output of the following C++ program code : 2
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;
}
5. Find and write the output of the following C++ program code : 3
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();
}
6. 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
{ ------------------------------------------}
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!” <<endl;
}
};
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
}
(i)Which concepts of object oriented programming out of the following is illustrated by Member Function 1 and
Member Function 2 combined together ? 2
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!” ?
1
(iii) Write complete definition for function 2. 1
(iv) Specify the type of constructors for function1 and function2. 1
7. Convert the following Infix expression to its equivalent Postfix expression,showing the stack contents
for each step of conversion. 2
A/(B+C)*D–E

8. 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. 2
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
9. 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 :
3
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;}
};
10. Write the definition of a member function INSERT() , DELETE() and DISPLAY() functions 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. 3*3=6
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();
};
11. Find the output of the following program: 2
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Change(char Msg[],int Len)
{ for(int Count=0;Count<Len;Count++)
{ if(islower(Msg[Count]))
Msg[Count] = toupper(Msg[Count]);
else if(isupper(Msg[Count]))
Msg[Count] = tolower(Msg[Count]);
else if (isdigit(Msg[Count]))
Msg[Count]=Msg[Count]+1;
else Msg[Count] = ‘*’;
} }
void main( )
{ char Message[ ]=”2005 Tests ahead”;
int Size=strlen(Message);
Change(Message,Size);
cout<<Message<<endl;
for(int C=0,R=Size – 1; C<=Size/2;C++,R--)
{ char Temp=Message[C];
Message[C]=Message[R];
Message[R]=Temp;
}
cout<<Message<<endl; }
12. Illustrate the use of #define in C++ to define a macro. 2
13. Define a class RESTRA in C++ with following description: 4
Private Members
• FoodCode of type int • Food of type String
• FType of type string • Sticker of type string
• A member function GetSticker() to assign the following values for Sticker as per the given FType:
FType Sticker

Vegetarian GREEN

Contains Egg YELLOW

Non-Vegetarian RED

4
14. Find output:

15. Read and answer the question: 3


16.

Considering the above Class Write complete definition for Push () and pop()
functions
Function should generate error report if overflow or under flow occurs. 3*2=6

17. Write complete definition for functions : 4*3=12


(i) EnQueue()for inserting elements of type string till user wants to insert elements
or queue size reached.
(ii) DeQue() to delete string elements from circular Queue till user wants or Queue
becomes empty.
(iii) to display all elements of queue().
18. What do you mean by function overriding .Explain with example and also
explain how it can be solved.
3
19. An array MAT[30][10] is stored in the memory along column wise with each element occupying 8 bytes of the
memory. Find out the Base address and the address of element MAT[20][5] , if the location MAT[3][7] is stored
at the address 1000. 3
20. Suppose a 1D array AR containing integers is arranged in ascending order. Write a user defined function in
C++ to search for one integer from AR with the help of binary search method, to show presence of the number in
the array. The function should have three parameters: (1) an array AR (2) the number to be searched and (3) the
number of
elements N in the array. 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy