1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

Embed Size (px)

Citation preview

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    1/12

    SAMPLE PAPER (SOLUTION- MARKING SCHEME )CS2013(BASED ON NEW PATTERN) COMPUTER SCIENCE [CODE083]CLASS XIIax Time : 3 hours Max Marks : 70

    1. (a) Write the prototype of a function named Percent, which takesan integer as value parameter and return a float type value. Theparameter should have a default value 10.AAns:- float Percent (int x=10);

    (2)

    1(b) Write the names of header files, which areNOT necessary torun the following program:#include #include #include

    #include void main(){char STR[80];gets(STR);puts(strrev(STR));}

    ns:-

    (1)

    1(c) Tarunaj has just started working as programmer in the JAGAT WORLD

    SOFTWARE company. In the company, he has got his first assignment todevelop a small C++ module to find the biggest number out of a given setof numbers stored in a one dimensional array. Somehow he has committed afew logical mistakes while writing this code and so he is not getting thedesired result from the code. Find out the mistakes and correct this C++code so that it provides the desired result (do not add any new statementin the code). Underline each correction made:

    int BIGFIND(int ARR[],int Size){int BIG=ARR[1]; //Statement 1

    for (int C=2;C

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    2/12

    //second element has 1for (int C=1;C BIG) //Statement 3BIG= ARR[C] //Statement 4

    1(d) Find output of the following program segment:int A[][3] = {{1,2,3}, {5,6,7}};for (int i = 1; i

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    3/12

    hiding possible.Define a class having both data and functions as members make alldata members private to hide its visibility/accessibility fromoutside the class. Make some member function as public that willbe used to interact with the outside world from main function.

    Data Encapsulation: Wrapping up of data and functions together in a

    single unit is known as Data Encapsulation. In a class, we wrap up the

    data and functions together in a single unit.

    Data Hiding: Keeping the data in private visibility mode of the class

    to prevent it from accidental change is known as Data Hiding.

    class Computer{char CPU[10];int RAM;public:

    Data Encapsulation

    void STOCK();

    void SHOW();

    };( Mark each for appropriate definitions)

    (1 Mark for appropriate example showing both)(2)(b) What is constructor overloading? Give an example to illustrate thesame...ANSWEREXAMPLE..class Exam{char Subject[20] ;

    int Marks ;public :

    Exam() //Function 1{

    strcpy(Subject, Computer ) ;

    Marks = 0 ;}Exam(char P[ ]) // Function

    2{strcpy(Subject, P) ;Marks=0 ;}

    Exam(int M) //Function 3{

    strcpy(Subject, Computer) ;

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    4/12

    Marks = M ;}Exam(char P[ ], int M) // Function 4{strcpy(Subject, P) ;

    Marks = M ;} };

    (2)(c) Define a class HandSet in C++ with following description:Private members:Make- of type stringModel- of type stringPrice- of type long intRating- of type charPublic Members:Function Read_Data to read an object of HandSet type.

    Function Display() to display the details of an object of HandSet type.Function RetPrice() to return the value of Price of an object of HandSettype. (4)

    --------------------------------- ANSWER 2(C)--------------------------------------------------------------------

    class HandSet {rivate :char Make[20];char Model[20];long int Price;

    char Rating;ublic:void Read_Data(){coutPrice; cin>>Rating;}

    void Display(){cout

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    5/12

    { return count; }};Write code in C++ to publically derive another class new_counter fromclass counter. Class new_counter should have the following additionalfunction members in the public visibility mode:(i) A parameterized constructor to initialize the value of count to thevalue of parameter.

    (ii) dec_count() to decrease the value of data member count by 1.(iii) Reset() to set the value of data member count to 0.

    ANSWER 2(D ) ..class new_counter : public counter{

    public:new_counter(unsigned int x){count=x;}void dec_count(){count--;}void Reset() {count=0;}};

    3 (a) Write a function TRANSFER(int A[], int B[], int Size) in C++ to copythe elements of array A into array B in such a way that all the negativeelements of A appear in the beginning of B, followed by all the positiveelements, followed by all the zeroes maintaining their respective ordersin array A. For example:If the contents of array A are:7, -23, 3, 0, -8,-3,4, 0The contents of array B should be-23 , -8, -3, 7, 3, 4, 0------------------------------------------------ANSWER 3(a)----------------------------------------------------#include#includevoid transfer(int a[],int b[],int size);void main(){int a[]= {7, -23, 3, 0, -8,-3,4, 0},b[8];transfer(a,b,8);for(int i=0;i

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    6/12

    void transfer(int a[],int b[],int size){int k=0;for(int i=0;i

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    7/12

    =800+4*13

    =852(Answer)

    3(c) Write a function in C++ to perform Insert operation in acircular Queue containing Players information (represented with thehelp of an array of structure PLAYER).-----------------------------ANSWER 3 ( c ) -----------------------------------------------------------#include#includestruct PLAYER{long PID; //Player ID

    char Pname[20]; //Player Name} p[3];int rear=-1, front=-1;void insert( PLAYER p1, int size){if((front==0 && rear==size-1)||front==rear+1){cout

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    8/12

    coutP.Pname;insert(P,3);coutch;}getch();}

    4.(a) A binary file Students.dat contains data of 10 students where

    each students data is an object of the following class:class Student{int Rno;char Name[20];public:void EnterData() {cin>>Rno; cin.getline(Name,20);void ShowData() {cout

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    9/12

    #include

    void countLines(){ifstream f;

    f.open("DIARY.TXT");int count=0;char line[200];

    while(f){f.getline(line,100);if (isdigit(line[0])) count++;}cout

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    10/12

    . ANSWER 4 ( c ) .#include#include#include#includeclass student{ char S_admno[10]; //Admission no. of studentchar S_Name[20]; //Name of studentint Percentage; //Marks percentage of studentpublic:void EnterData(){ gets(S_admno); gets(S_Name); cin>>Percentage;}void DisplayData(){ cout

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    11/12

    f.open("STUDENT.DAT ",ios::binary);while(1) {f.read((char*)&p,sizeof(p));if(f.eof()==1) break;else

    if(p.Ret_Per()>75) p.DisplayData();}f.close();}5. (a)-(i)- (ANSWER) NO, MNo column cannot be made as Primary Keybecause valus in this column are not UNIQUE, value 102 is repeatedmore than one time. It is violating the Primary Key constraints socannot act as Primary Key.(Same member can purchase many different type of products, hencerespective MNO can be repeated.)

    5. (a)-(ii)- (ANSWER) Degree=No. of columns= 4 , Cardinality=No. ofrows = 55.(b)-(i)-SELECT TITLE FROM SUBJECT WHERE MARKS_PRAC=0;(II) SELECT COUNT(TCODE),SUB_CODE FROM TEACHER GROUP BY SUB_CODE;(III) SELECT NAME FROM TEACHER ORDER BY SUB_CODE;(IV) SELECT CODE , TITLE, (MARKS_THEORY+MARKS_PRAC) AS TOTALMARKS FROM SUBJECT ;5.(C) SELECT SUBJECT.TITLE , TEACHER.NAME FROM SUBJECT ,TEACHER where SUBJECT.CODE=TEACHER.SUB_CODE ;5.(d)-(i) output : 100

    70

    (ii)output :4 Shabnam5 Rashika6 Vidushi7 Yash

    5.(e) In subject table code can be made PRIMARY KEY. In TEACHERtable TCode can be made PRIMARY KEY7.(a) RADIO WAVE7.(b) SMTP protocol is used to receive emails.7.(c)COOKIE S -Information sent by webserver to the web browser.7.(d) client-side script

    7.(e) Free Software: The S/Ws is freely accessible and can be freelyused changed improved copied and distributed by all and payments areneeded to make for free S/W.Freeware: Freeware are the software freely available , which permitredistribution but not modification (and their source code is notavailable). Freeware is distributed in Binary Form (ready to run)without any licensing fees.Note- Crossed line which are marked green are not part of thesolution, only yellow colored lines are the actual solution to be

  • 7/29/2019 1312767878cbse Sample Paper (Cs) 2013 With Solution (1)-1

    12/12

    written in exam.I have tried my best to avoid any mistakes while preparing thesolution, but still there might be few chances that errors mightexist... so, please feel free to post your comments / suggestions ormail me at [email protected] . Your suggestions will be mostwelcomed and appreciated.

    ****************************THE END**********************************