48133.pdf

  • Uploaded by: Abhinav
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 48133.pdf as PDF for free.

More details

  • Words: 1,291
  • Pages: 8
BSC/BCA-2ND Object Oriented Programming (SCT-155/CAT-153) Assignment-3 Date of allocation of Assignments

22TH MAR 2019 2nd APR 2019

Date of Submission of Assignments

Instructions: 1. You are required to do assignment according to your grouping A/B/C/D/E/F/G only. 2. You are required to use A4 size sheets and staple those sheets with University’s official assignment front page. 3. The submitted programs code has to be compiled without errors by GNU C/C++ compiler or turbo C++ compiler.

4. Use comments and brief explanation of code. Assignment Assignment 1 Assignment 2 Assignment 3 Assignment 4 Assignment 5 Assignment 6 Assignment 7

S

UIDs

N

GROUPIN

o.

G

1

A

Group 18BCA1085 - 18BCA1102 18BCA1103 - 18BCA1112 18BCA1113 - 18BCA1125 18BCA1126 - 18BCA1138 18BCA1139 - 18BCA1154 18BCA1156 - 18BCA 1195 18BCA1201 - 18BCA3021 and 17BCA1489,1510,1571

ASSIGNMENT-III

1) Write a function in C++ to count the number of vowels present in a text file “NOTES.TXT”. 2) Write a function in C++ to print the count of word “the” as an independent

word

in

for

if

content

example,

the

a

text of

the

file file

“STORY.TXT”. “STORY.TXT”

is

There was a monkey in the zoo. The monkey was very naughty.

Then the ouput of the program should be 2. 3) Assuming that a text file named FIRST.TXT contains some text written into it, write a function named vowelwords(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain only those words from the file FIRST.TXT which start with a lowercase vowel (i.e., with 'a', 'e', 'i', 'o', 'u'). For example, if the file FIRST.TXT contains Carry umbrella and overcoat when it rains Then the file SECOND.TXT shall contain umbrella and overcoat it 4) Write a program to print the address of a variable whose value is input from user. 5) Write a program to print the address of the pointer to a variable whose value is input from user.

2

B

1) Write a user defined function in C++ to read the content from a text file “MYbook.txt”, count and display the number of blank spaces present in it. 2) Write a function in C++ to count and display the number of lines not starting with alphabet 'A' present in a text file "STORY.TXT". Example: If the file "STORY.TXT" contains the following lines, The rose is red. A girl is playing there. There is a playground. An aeroplane is in the sky. Numbers are not allowed in the password. The function should display the output as 3. 3) Differentiate between compile-time and run-time polymorphism with suitable programs. 4) Write a program to print the value of the address of the pointer to a variable whose value is input from user.

5) Write a program to print a number which is entered from keyboard using pointer.

3

C

1) Write a function in C++ to count the number of alphabets present in a text file “NOTES.TXT”. 2) Assuming that a text file named FIRST.TXT contains some text written into it, write a function named copyupper(), that reads the file FIRST.TXT and creates a new file named SECOND.TXT contains all words from the file FIRST.TXT in uppercase. 3) Differentiate between virtual functions and pure virtual functions with suitable programs. 4) Write a function which will take pointer and display the number on screen. Take number from user and print it on screen using that function. 5) Write a program to find out the greatest and the smallest among

three numbers using pointers. 4

D

1) Write a function which reads an already existing file “text1.txt” and write digits (0-9) in to a new text file “DIGIT.TXT” and non digit files intoNONDIG.TXT. 2) Write a program that reads a file containing a list of numbers and writes two files, one with all the numbers divisible by 3 and another containing all the other numbers. 3) Illustrate the random accessing of text file with suitable program. Explain why it is important as compared to sequential accessing. 4) Write a program to find the factorial of a number using pointers. 5) Write a program to reverse the digits a number using pointers.

5

E

1) Write a function in C++ to count the number of lines present in a text file“STORY.TXT”. 2) Design a file format to store a person's name, address, and other information. Write a program to read this file.

3) Compile the below written code and find out the errors. After debugging give the output of this program? #include using namespace std; class stu { protected: int rno; public: void get_no(int a) { rno = a; } void put_no(void) { } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x, float y) { part1 = x; part2 = y; } void put_marks() { } }; class sports { protected: float score; public: void getscore(float s) { score = s; } void putscore(void) { } }; class result: public test, public sports

{ float total; public: void display(void); }; void result::display(void) { total = part1 + part2 + score; put_no(); put_marks(); putscore(); cout << "Total Score=" << total << "\n"; } int main() { result stu; stu.get_no(123); stu.get_mark(27.5, 33.0); stu.getscore(6.0); stu.display(); return 0; } 4) Consider the following code, find errors if any and write the correct code and output: #include using namespace std; int main () { char first, second; cout << "Enter a word: "; first = cin.get(); cin.sync(); second = cin.get(); cout << first << endl; cout << second << endl; return 0; } 5) Consider the following code, find errors if any and write the correct code and output: #include #include using namespace std; int main () { char ch;

streambuf * p; ofstream os ("test.txt"); pbuf = os.rdbuf(); do { ch = cin.get(); p -> sputc(ch); } while (ch != '.'); os.close(); return 0; }

6

F

1) Write a C++ program that update the contents in a text file. 2) Write a C++ program, which initializes a string variable to the content "Time is a great teacher but unfortunately it kills all its pupils. Berlioz" and outputs the string to the disk file OUT.TXT. You have to include all the header files if required. 3) Demonstrate the use of abstract class in real-world programming and illustrate how it is different from concrete class. 4) Write a program to read the data from text file. And display the output in another file. 5) Write a program to read the data from text file. And display the output on screen.

7

G

1) How updation is done in sequential file? Explain in detail with suitable examples. 2) Write a C++ program to write number 1 to 100 in a data file NOTES.TXT. 3) Compile the below written code and find out the errors. After debugging given the output of this program. #include using namespace std; class stu { protected: int rno;

public: void get_no(int a) { rno = a; } void put_no(void) { } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x, float y) { part1 = x; part2 = y; } void put_marks() { } }; class sports { protected: float score; public: void getscore(float s) { score = s; } void putscore(void) { } }; class result: public test, public sports { float total; public: void display(void); }; void result::display(void) { total = part1 + part2 + score; put_no();

put_marks(); putscore(); cout << "Total Score=" << total << "\n"; } int main() { result stu; stu.get_no(123); stu.get_mark(27.5, 33.0); stu.getscore(6.0); stu.display(); return 0; }

4) Write a program to read the data from binary file. And display the output in another file. 5) Write a program to read the data from binary file. And display the outp ut on screen.

More Documents from "Abhinav"