English

Science (English Medium) Class 12 - CBSE Important Questions for Computer Science (C++)

Advertisements
[object Object]
[object Object]
Subjects
Popular subjects
Topics
Advertisements
Advertisements
Computer Science (C++)
< prev  21 to 40 of 75  next > 

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#

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++

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

class SCHOOLS
{
    int SCode;        //School Code
    char SName[20];   //School Name
    int NOT;          // Name of Teachers in the school

public:
    void Display()
    {
       cout<<SCode<<"#"<<SName<<"#" << NOT << endl;
       int RNOT() {return NOT;}
};
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++

Find the output of the following C++ code considering that the binary file SCHOOL.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 Educa t for Life School 50
1005 Guru Shiahya Sadan 195
1004 Holy Education School 140
1010 Play 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(S*sizeof(S));
     SFIN.read((char*)&S, sizeof(S));
     S.Display();
     cout<<"Record : "<<SFIN.tellg()/sizeof(S) + l <<endl;
     SFIN.close();
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Implementation of Basic File Operations on Text and Binary File in C++

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

1) new

2) While

3) case

4) Num_2

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++

Anil typed the following C++ code and during compilation, he found three errors as follows :

1) Function strlen should have a prototype

2) Undefined symbol cout

3) 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;
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Header File - fstream.h

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>>CB ;
     switch(CH)
     case 'A' · cout<<"Ant"; Break ;
     case 'B' · cout<<"Bear"; Break;
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++

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

Note : Assume au· required header files are already included in the program.

#define Diff(N1,N2) ((N1>N2)?Nl-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)<< '#';
    }
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Advantages of Object Oriented Programming Over Earlier Programming Methodologies in C++

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((*Poi nt)%10==0)
            *Point /= 2;
         else
            *Point -= 2;
         if((*Point) %5==0)
            *Point /= 5;
         Point++;
      }
      for(int L = 5; L>=O; L--)
          cout<<Score[L]<<"*";
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias

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=O; R<N; R++)
   {
       for(int C = 0; C< M; C++)
·        cout<<DOCK[R][C]<<" ";
       cout<<endl;
    }
}
1)
2)
3)
4)
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)

Differentiate between protected .and private me~bers 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++.

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Using Private and Public Visibility Modes, Default Visibility Mode (Private)

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(TTit1e,"FIRST Test"); Score=O;
    };
    TEST(TEST &T)    //Member Function 2
    {
         TCode=E.TCode+1;
         strcpy(TTitle , T.TTitle);
         Score=T.Score;
     }
};

void main()
{
   __________    //Statement 1
   __________    //Statement 2
}

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

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

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)

Write the definition of a class BOX 1n C++ with the 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()   // 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

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Using Private and Public Visibility Modes, Default Visibility Mode (Private)

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
}

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

Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance

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

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

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

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Inheritance in C++

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.
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias

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 a number of rows and M represents the 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

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Pointers and Arrays - Array of Pointers, Pointer to an Array (1 Dimensional Array), Function Returning a Pointer, Reference Variables and Use of Alias

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();
};
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Member of a Class - Data Members and Member Functions (Methods)

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.

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Function Call by Reference

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, lstName, Add+Subtract, namel

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++

Observe the following program very carefully and write the names of those header files (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=O;
    while(Txt[Count]!='\0')
    if (isalpha(Txt[Count]))
       Txt[Count++]='@';
    else
       Txt[Count++]='#';
    puts(Txt);
}
Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: ifstream, ofstream, Classes

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 MaxSpeed=60.5;
void main()
{
   int MySpeed
   char Alert='N';
   cin>>MySpeed;
   if MySpeed>MaxSpeed
    Alert='Y';
    cout<<A1ert<<endline;
}

 

Appears in 1 question paper
Chapter: [6] Object Oriented Programming in C++
Concept: Concept of Object Oriented Programming in C++
< prev  21 to 40 of 75  next > 
Advertisements
Advertisements
CBSE Science (English Medium) Class 12 Important Questions
Important Questions for CBSE Science (English Medium) Class 12 Biology
Important Questions for CBSE Science (English Medium) Class 12 Chemistry
Important Questions for CBSE Science (English Medium) Class 12 Computer Science (C++)
Important Questions for CBSE Science (English Medium) Class 12 Computer Science (Python)
Important Questions for CBSE Science (English Medium) Class 12 English Core
Important Questions for CBSE Science (English Medium) Class 12 English Elective - NCERT
Important Questions for CBSE Science (English Medium) Class 12 Entrepreneurship
Important Questions for CBSE Science (English Medium) Class 12 Geography
Important Questions for CBSE Science (English Medium) Class 12 Hindi (Core)
Important Questions for CBSE Science (English Medium) Class 12 Hindi (Elective)
Important Questions for CBSE Science (English Medium) Class 12 History
Important Questions for CBSE Science (English Medium) Class 12 Informatics Practices
Important Questions for CBSE Science (English Medium) Class 12 Mathematics
Important Questions for CBSE Science (English Medium) Class 12 Physical Education
Important Questions for CBSE Science (English Medium) Class 12 Physics
Important Questions for CBSE Science (English Medium) Class 12 Political Science
Important Questions for CBSE Science (English Medium) Class 12 Psychology
Important Questions for CBSE Science (English Medium) Class 12 Sanskrit (Core)
Important Questions for CBSE Science (English Medium) Class 12 Sociology
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×