OOP1
OOP1
Procedure • Students should read the Pre-lab Reading assignment before coming to lab.
• Students should complete the Pre-lab Writing assignment before coming to lab.
• In the lab, students should complete Labs1.1 through 1.2 in sequence. Your
instructor will give further instructions as to grading and completion of the
lab.
• Students should complete the set of lab tasks before the next lab and get
them checked by their lab instructor.
File handling in C++ allows you to work with a wide variety of files,
including text files, binary files, and other types of files. You can read
data from files, write data to files, and manipulate the contents of files
in various ways. This can be useful for a variety of applications, such
as data processing, file conversion, and more.
ANSWER:
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the number of rows (half the height of the diamond): ";
cin >> n;
return 0;
}
OUTPUT:
ANSWER:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
vector<string> strList = {"ali", "ahmad", "", "abbas”,"nasir"};
string searchWord;
OUTPUT:
• Write a program in C++ to read the numbers (45,56,12,8,5,98) from a file, and
find the largest number in the file, and then write the answer back to the same
file?
ANSWER:
OUTPUT:
ANSWER:
#include <iostream>
using namespace std;
int main() {
int arr[] = {10, 20, 30, 40, 50};
OUTPUT:
. Write a program in C++ to read an equation from a file, solve it, and then write the
answer back to the same file?
ANSWER: