OOP Lab Task
OOP Lab Task
int main() {
int arr[5];
return 0;
}
Program .2
#include <iostream>
int main()
int arr[2][3];
cout << "Enter 6 integers to fill the 2x3 matrix:" << endl;
}
cout << endl;
return 0;
Program . 3
#include <iostream>
#include <string>
#include <algorithm>
int main() {
string name;
getline(cin, name);
reverse(name.begin(), name.end());
cout << "Your name in reverse order is: " << name << endl;
return 0;
}
Program . 4
#include <iostream>
return num % 2 == 0;
int main() {
int number;
if (isEven(number)) {
} else {
}
return 0;
Program . 5
#include <iostream>
int temp = a;
a = b;
b = temp;
int main() {
swap(num1, num2);
return 0;
Program . 6
#include <iostream>
int main()
*ptr = 57;
cout << "Updated value of num: " << num << endl;
return 0;
Program. 7
#include <iostream>
int main() {
int size;
cout << "Enter " << size << " integers to fill the array: " << endl;
for (int i = 0; i < size; i++) {
delete[] arr;
return 0;
Task . 8
#include <iostream>
using namespace std;
struct Person {
string name;
int age;
};
void passByValue(Person p) {
p.age += 5;
cout << "Inside passByValue function: " << p.name << " is now " << p.age << " years old." <<
endl;
p.age += 5;
cout << "Inside passByReference function: " << p.name << " is now " << p.age << " years old."
<< endl;
int main() {
cout << "Initial values in main: " << person1.name << " is " << person1.age << " years old."
<< endl;
passByValue(person1);
cout << "After passByValue function in main: " << person1.name << " is " << person1.age << "
years old." << endl;
passByReference(person1);
cout << "After passByReference function in main: " << person1.name << " is " << person1.age
<< " years old." << endl;
return 0;
}
Task . 9
#include <iostream>
struct Person {
string name;
int age;
};
cout << "Enter details for person " << i + 1 << ":" << endl;
}
}
cout << "Person " << i + 1 << ": " << people[i].name << ", Age: " << people[i].age << endl;
int main()
Person people[SIZE];
input(people, SIZE);
display(people, SIZE);
return 0;
Task . 10
#include <iostream>
#include <cstdlib>
int main() {
int size;
if (arr == nullptr ) {
return 1;
cout << "Enter " << size << " elements for the array:" << endl;
free(arr);
return 0;