Professional Documents
Culture Documents
C++ Language
C++ Language
QUESTION 1
(a)
#include <iostream>
int result = g + h + y;
cout << "The sum of the three integers is: " << result << endl;
int main() {
muddy(1, 2, 3);
return 0;
(b)
#include <iostream>
#include <fstream>
int result = g + h + y;
ofstream outFile("my_file.txt");
if (outFile.is_open()) {
outFile << "The sum of the three integers is: " << result << endl;
outFile.close();
} else {
int main() {
abby(1, 2, 3);
return 0;
(c)
#include <iostream>
#include <fstream>
void advancedSecondarySchoolAddition() {
ifstream inFile("my_file.txt");
int result = g + h + y;
outFile << "The sum of the three integers is: " << result << endl;
inFile.close();
outFile.close();
} else {
}
}
int main() {
advancedSecondarySchoolAddition();
return 0;
(d)
Part (a)
#include <iostream>
cout << "The sum of the two floats and one integer is: " << result << endl;
int main() {
return 0;
Part (b)
#include <iostream>
#include <fstream>
ofstream outFile(outputFile);
if (outFile.is_open()) {
outFile << "The sum of the two floats and one integer is: " << result << endl;
outFile.close();
} else {
int main() {
return 0;
Part (c)
#include <iostream>
#include <fstream>
ifstream inFile(inputFile);
ofstream outFile(outputFile);
float g, h;
int y;
outFile << "The sum of the two floats and one integer is: " << result << endl;
inFile.close();
outFile.close();
} else {
int main() {
advancedSecondarySchoolAddition("input.txt", "output.txt");
return 0;
QUESTION 2
#include <iostream>
#include <fstream>
float result = g + h + y;
cout << "The sum of the two floats and one integer is: " << result << endl;
float result = g + h + y;
ofstream outFile("my_file.txt");
if (outFile.is_open()) {
outFile << "The sum of the two floats and one integer is: " << result << endl;
outFile.close();
} else {
void advancedSecondarySchoolAddition() {
ifstream inFile("my_file.txt");
int y;
float result = g + h + y;
outFile << "The sum of the two floats and one integer is: " << result << endl;
inFile.close();
outFile.close();
} else {
int main() {
advancedSecondarySchoolAddition();
return 0;