0% found this document useful (0 votes)
59 views2 pages

Instructions:: Assignment 3

The document provides instructions for two tasks. Task 1 involves reading a binary character array from a file, dynamically allocating an integer array of the correct size, reading the data into the array, and finding the maximum consecutive ones. Task 2 involves reading lines from an input file, passing each line to a function to count characters and append the count, writing the updated lines to an output file, and displaying the total characters. Plagiarism will result in zero marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

Instructions:: Assignment 3

The document provides instructions for two tasks. Task 1 involves reading a binary character array from a file, dynamically allocating an integer array of the correct size, reading the data into the array, and finding the maximum consecutive ones. Task 2 involves reading lines from an input file, passing each line to a function to count characters and append the count, writing the updated lines to an output file, and displaying the total characters. Plagiarism will result in zero marks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 3

Instructions:
1. You are strictly not allowed to use anything other than pointers and dynamic
arrays.
2. If plagiarism found, zero marks will be awarded.

Task 1
A 1D binary character array is given to you in file “task1.txt”. You are required to find out
maximum consecutive ones in the array.
Note: Read the file and find the exact length of data in a separate function. Use that size to
create a dynamic integer array using pointers. Then, read the file again and insert data into this
dynamic array of exact calculated size. Then You are required to find out maximum consecutive
ones in the array.

task1.txt.

11010101111110110111010

Expected output:
- maximum consecutive ones are: 111111
- Starting index is: 7
- Length is: 6

Task 2
Write a C++ program which reads text data line by line from a text file(Name: input.txt). A user
defined function is used to read data line by line from file (Name of function is ReadAllLines()).
After reading each line this line is passed to another function (Name: updateLine()) which counts
the No. of characters in line and insert no. of characters at the end of line and returns updated
line contents. First method (ReadAllLines()) writes this line in another text file(Name:
UpdatedInput.txt). Program also displays Total No. of characters found in File (Input.txt) at the
end.
Note: You will always pass a pointer of each line to function updateLine() method.
Output:

Input.txt UpdatedInput.txt
I am a student of UCP. I am a student of UCP. 22
I am in second Semester. I am in second Semester. 24
I am in Love with UCP. I am in Love with UCP.22
Output:
Total characters found in file are: 68

You might also like