330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer...

5
92 Computer Science Computer Science 330 Assignment Max. Marks: 20 Note: (i) All questions are compulsory. The marks for each question are given at the same place. (ii) Write your name, enrolment number, AI name and subject etc. on the top of the first page of the answer sheet. 1. Answer any one of the following questions in about 40-60 words : 2 a) Write one advantage and one disadvantage each of fixed length records and variable length records. b) XYZ Corp. Ltd. has stored the payroll data of its employees in a database. Give one example each of the situations where retrieval and reproduction of this data may be required. c) Mohit has a photograph in his computer. He wants to use this photograph as the background of his desktop but he does not know how to do it. Write steps to tell Mohit how to set this photograph as the desktop background. d) Saumya wants to create a Startup disk so that she can use it later when required. Write steps to tell her how to create a Startup disk. 2. Answer any one of the following questions in about 40-60 words: 2 a) Two schools in a locality have their own computer networks. To share the teaching and learning modules, the schools decide to interconnect their networks. They join their networks by a 150m long twisted pair cable. Based on this context answer the following questions:(i)The schools are not able to share the data as the signal gets weak during transmission. How can this problem be solved?(ii)What kind of network (LAN, MAN, or WAN) will be formed by this interconnection of networks? b) Is it possible to send email to multiple people in such a way that none of these people knows to whom else has the email been sent? If yes, then how? c) Evaluate the following C++ expressions (assume x = -1, y = 2): (i) x > y (ii) x+y >= y d) What will be the value of x after execution of the following C++ code: int x = 5, float y=2.5; if (x < y) x = x+y; else x = x-y; 3. Answer any one of the following question in about 40-60 word each : 2 a) Write a function prototype (in C++) for a function which accepts two integers as parameters and returns their difference. b) Write a program that accepts 10 integers in an array and then reverses the array. For example, if the user enters 2, 4, 3, 6, 7, 8, 9, 7, 12, 15 in the array then the array should become 15, 12, 7, 9, 8, 7, 6, 3, 4,

Transcript of 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer...

Page 1: 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer Science (330).pdf · 330 Assignment Max. ... Write a menu driven program in C++

92 Computer Science

Computer Science330

Assignment

Max. Marks: 20

Note: (i) All questions are compulsory. The marks for each question are given at the same place.(ii) Write your name, enrolment number, AI name and subject etc. on the top of the first page of the

answer sheet.1. Answer any one of the following questions in about 40-60 words : 2

a) Write one advantage and one disadvantage each of fixed length records and variable length records.b) XYZ Corp. Ltd. has stored the payroll data of its employees in a database. Give one example each of the

situations where retrieval and reproduction of this data may be required.c) Mohit has a photograph in his computer. He wants to use this photograph as the background of his

desktop but he does not know how to do it. Write steps to tell Mohit how to set this photograph as thedesktop background.

d) Saumya wants to create a Startup disk so that she can use it later when required. Write steps to tell herhow to create a Startup disk.

2. Answer any one of the following questions in about 40-60 words: 2a) Two schools in a locality have their own computer networks. To share the teaching and learning modules,

the schools decide to interconnect their networks. They join their networks by a 150m long twisted paircable. Based on this context answer the following questions:(i)The schools are not able to share the dataas the signal gets weak during transmission. How can this problem be solved?(ii)What kind of network(LAN, MAN, or WAN) will be formed by this interconnection of networks?

b) Is it possible to send email to multiple people in such a way that none of these people knows to whomelse has the email been sent? If yes, then how?

c) Evaluate the following C++ expressions (assume x = -1, y = 2):(i) x > y(ii) x+y >= y

d) What will be the value of x after execution of the following C++ code:int x = 5, float y=2.5;if (x < y)x = x+y;else x = x-y;

3. Answer any one of the following question in about 40-60 word each : 2a) Write a function prototype (in C++) for a function which accepts two integers as parameters and returns

their difference.b) Write a program that accepts 10 integers in an array and then reverses the array. For example, if the user

enters 2, 4, 3, 6, 7, 8, 9, 7, 12, 15 in the array then the array should become 15, 12, 7, 9, 8, 7, 6, 3, 4,

Page 2: 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer Science (330).pdf · 330 Assignment Max. ... Write a menu driven program in C++

93Computer Science

2 after reversal. The program should then display the reversed array. Do not use more than 1 array in theprogram.

c) Observe the class Movie given below:class Movie{ char Title[30], Genre[20];

long int Cost; int YearOfRelease;float Cost_per_print(int n){

return Cost/5.0 + n;}public:

void ReadData();void Display();Cost_per_print(n);

};Write a constructor for this class which initializes Title and Genre to “Not Known” and Cost to 0.

d) Write a structure specification in C++ for the record given below:Name: A string of 25 characters (includingNull character)

Class: IntegerSection: CharacterRoll_No: IntegerCall this structure STUDENT.

4. Answer any one out of the following four questions in about 100 to 150 words 4a) Write the equivalent C++ expressions for the following Algebraic expressions:

(i) )(x BAC

BCAB

(ii) )(333 baabba

(iii) 234 4xy k xy

b) Write a program to print all the multiplication tables from 11 to 20 up to first 10 multiples of each.

c) Write a menu driven program in C++ to calculate the simple interest or compound interest dependingupon the user’s choice. Write and use functions to calculate simple interest and compound interest.

d)

How can we create above directories and copy “File: SSC330.txt” file from NIOS directory to AICTEdirectory?

Page 3: 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer Science (330).pdf · 330 Assignment Max. ... Write a menu driven program in C++

94 Computer Science

5. Answer any two of the following questions in about 100-150 words. 4

a) In an off-season sale following schemes of discounts are offered to the customers:

(i) If the customer buys items for a total marked price of Rs. 1000/- to Rs. 2000 then the discount is20%.

(ii) If the customer items for a total marked price of Rs. 2001/- to Rs. 5000/- then the discount is 30%.

(iii) If the customer buys items for a total marked price of more than Rs. 5000, then the discount s 40%.

Write a program to input the value of Total Marked Price from the user and then calculate the discount,and gross total. Then apply VAT @12.5% on the gross total. The program should display The TotalMarked Price, Discount, Gross Amount, VAT, and Net Amount Payable by the customer. The programshould continue as long as the user wants. Write and use a function to calculate the discount, gross total,VAT, and Net Amount Payable.

b) Write a program in C++ to input the ItemCode, ItemName, CP, and SP of 10 items and then display thisitems list along with profit for each item. Profit is calculated as SP-CP. Write and use a class ITEM in thisprogram.

c) Declare a structure telerec in C++, containing name (20 characters) and telephone number. Write aprogram to maintain a file of telephone records. The program should allow the following functions on thefile:

1) To append records in the file.

Display the telephone number(s) for a given name. If the name does not exist then display error message“record not found”.

d) Consider the following class declaration and answer the questions below:class zoo{

char locations [20]; protected:int no_of_animals;public:void inputdata (char, int); void outputdata ();

};class animal : protected zoo{

int tail;protected:int legs;public:void readdata (int, int);void write data ();

Page 4: 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer Science (330).pdf · 330 Assignment Max. ... Write a menu driven program in C++

95Computer Science

};

class carnivorous : private animal

{

int paw_size;

public:

void fetchdata (int);

void displayed ();

};

a. Name the base class and derived class of the class animal.

b. Name the data member (s) that can be access from the function displayed ().

c. Name the data member (s) that can be accessed by an object of carnivorous class.

d. Is the member function outputdata accessible to the objects of the animal class?

6. Make any one project out of the four given below. 6a. Write a menu driven program in C++ to perform the following functions on a binary file “BOOK.DAT”

containing objects of the following class:

class Book{ int BookNo;

char Book_name[20];public:

// function to enter book detailsvoid enterdetails();//function to display Book detailsvoid showdetails();//function to return Book_noint Rbook_no() {return Book_no;}//function to return Book_nameint Rbook_name() {return Book_name;}

};

a) Append Records

b) Modify a record for a given book no.

c) Delete a record with a given book no.

d) Search for a record with a given Book name

b) Define a class student with the following specifications:

Private members of the class:

Admission Number - An Integer

Name - string of 20 characters

Page 5: 330 Assignment - National Institute of Open Schoolingnios.ac.in/media/documents/TMAsr13/19D.Computer Science (330).pdf · 330 Assignment Max. ... Write a menu driven program in C++

96 Computer Science

Class - Integer

Roll Number - Integer

Public members of the class:

getdata() - To input the data

showdata() - To display the data

Write a program to define an array of 10 objects of this class, input the data in this array and then displaythis list in the ascending order of Roll Number or in the alphabetical order of Name depending upon theuser’s choice.

c. Write a program to input integer data in two arrays. Sort one of the arrays in ascending order and theother in descending order. Then merge them into a third array so that the data in the third array is inascending order. The program should then display the data from all the three arrays.

d. Declare a structure telerec in C++, containing name (20 characters) and telephone number. Write aprogram to maintain a file of telephone records. The program should allow the following functions on thefile:

1) To append records in the file.

2) Display the name for a given telephone number. If the telephone number does not exist then displayerror message “record not found”.

3) Display the telephone number(s) for a given name. If the name does not exist then display errormessage “record not found”.

Write this program using pointer to structure to access the data members.