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

Assignment

The document provides instructions for an assignment with 3 tasks. It specifies that students must submit a zip file by April 10th, 2023 containing C++ programs, screenshots, and input/output files. The tasks involve: 1) Checking the length of a string and reversing or sorting it, 2) Counting and sorting vowels/consonants from a file, and 3) Reading student registration numbers from a file and writing a formatted output to another file. Plagiarism is not allowed and late submissions will not be accepted.

Uploaded by

Arshaq Waseem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Assignment

The document provides instructions for an assignment with 3 tasks. It specifies that students must submit a zip file by April 10th, 2023 containing C++ programs, screenshots, and input/output files. The tasks involve: 1) Checking the length of a string and reversing or sorting it, 2) Counting and sorting vowels/consonants from a file, and 3) Reading student registration numbers from a file and writing a formatted output to another file. Plagiarism is not allowed and late submissions will not be accepted.

Uploaded by

Arshaq Waseem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Central Punjab

Assignment # 1

Time & Date Deadline: 10th April, 2023 11:59 PM


Course: Programming Fundamentals (PF)

Submission Instructions:
1) You have to submit 1 zip file containing:
• MS word document containing C++ programs with screen shot of console
• .cpp file of the program and input files where required
2) You have to upload your assignments on CMS.
3) Plagiarism is not acceptable. If someone’s assignment is plagiarized, that student will be given F
straight away, so beware.
4) The deadline for this assignment is April 10th, 2022, 11:59 pm. No late submission will be
accepted.

Learning Objectives: Demonstrate knowledge of character arrays and file handling in programming
(C++).

Task 1:

Write a C++ program asks user for a string and checks its length. If the length of string is even then display
it in reverse order and if the length is odd, sort the string alphabetically.

Sample Output:

Sample output 1:
Enter a string: UCP Lahore
Length is: 10
String is: erohaL PCU
Sample output 2:
Enter a string: file handling
Length is: 13
String is: adefghiillnn
Task 2:
Write a C program which takes a string of unknown length from the file input.txt. Then find the total number of
vowels and consonants in that string, also sort vowels in descending order and write the results in output.txt. You also
have to write sorting code for sorting of vowel array. Note that the count of vowels is case independent.

Input.txt:

This is a string which contains vowels and consonants. Our task is to sort them in descending order, and print their
count.

Output.txt:
Total Consonants: 66
Total Vowels: 33
Total ‘i’: 10
Total ‘o’: 9
Total ‘a’: 6
Total ‘e’: 6
Total ‘u’: 2

Task 3:
Write a C++ program that reads registration numbers from the file students.txt and after required formatting write it
records.txt as shown below.

The sample input file:

students.txt
FA21-BCS-110
FA20-BCS-122
SP21-BSE-134
FA21-BCS-137
FA21-BSE-145

The sample output file:

record.txt
Semester Program Roll No.
FA21 BCS 110
FA20 BCS 122
SP21 BSE 134
FA21 BCS 137
FA21 BSE 145

You might also like