Fa24 Bcs 001 Assignment 4
Fa24 Bcs 001 Assignment 4
#include <iostream>
#include <string>
struct studentType {
string studentName;
string studentLName;
int testScore;
char grade;
};
cout << "Enter details for Student " << i + 1 << ":\n";
students[i].grade = 'A';
students[i].grade = 'B';
students[i].grade = 'C';
students[i].grade = 'D';
else
students[i].grade = 'F';
highest = students[i].testScore;
}
return highest;
if (students[i].testScore == highestScore) {
int main() {
studentType students[SIZE];
readStudentData(students, SIZE);
assignGrades(students, SIZE);
int highestScore = findHighestScore(students, SIZE);
cout << "\nHighest Test Score: " << highestScore << endl;
return 0;
}
Task 2
#include<iostream>
#include <string>
#include <fstream>
ifstream in("data.txt");
if (!in)
return;
getline(in, str);
in.close();
char ch = str[i];
if (ch != ',' && ch != '.' && ch != ';' && ch != ':' && ch != '!' && ch
!= '?')
cleared_sentence += ch;
}
return cleared_sentence;
ofstream out("output.txt");
if (!out)
return;
char ch = str[i];
if (!new_str.empty())
out << new_str << " " << new_str.length() << endl;
new_str = "";
else
new_str += ch;
}
if (!new_str.empty())
out << new_str << " " << new_str.length() << endl;
out.close();
int main()
string str;
read_file(str);
output_file(cleaned_sentence, length_of_cleanedSentence);
return 0;
Output
Data. txt=
This is a test
Result is
Task 3
#include<iostream>
#include<string>
#include <fstream>
ifstream in("input.txt");
if (!in)
return;
if (!getline(in, str1))
if (!getline(in, str2))
in.close();
ofstream out("output.txt");
if (!out)
return;
if (str1[i] == str2[i])
if (str1[i] == str2[i])
{
out.close();
int main()
string str1;
string str2;
read_file(str1, str2);
return 0;
Output:
Input.txt=
processing
programming
Result