0% found this document useful (0 votes)
16 views7 pages

Lab

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

Lab

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

Name : Tanzimul Islam Polok

Id : 23-55304-3

1. #include <iostream>

using namespace std;

int main() {

int row = 3;

int col = 3;

int arr[row][col] = {{1, -2, 3},{-4, 5, -6},{7, 8, -9}};

for (int i = 0; i < row; ++i) {

for (int j = 0; j < col; ++j) {

if (arr[i][j] < 0) {

arr[i][j] = 0;

cout << "Modified Array:" << endl;

for (int i = 0; i < row; ++i) {

for (int j = 0; j < col; ++j) {

cout << arr[i][j] << " ";

}
cout << endl;

return 0;

2. #include<iostream>

using namespce std;

int main() {

int arr[3][3] = {{5, 10, 3}, {8, 2, 15}, {7, 9, 1}};

int min = arr[0][0];

int row = 0;

int col= 0;

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 3; j++) {

if (arr[i][j] < min) {


min = arr[i][j];

row = i;

col = j;

cout << "Smallest element: " << min <<endl;

cout << "Row index: " << row << endl;

cout << "Column index: " << col <<endl;

return 0;

3. #include <iostream>

#include <string>

using namespace std;


class Student {

private:

int roll_num;

float cgpa;

int marks;

int age;

public:

Student() {

roll_num = 0;

cgpa = 0.0;

marks = 0;

age = 0;

void setValue(int roll, float cg, int m, int a) {

roll_num = roll;

cgpa = cg;

marks = m;

age = a;

}
void display() {

cout << "Roll Number: " << roll_num << endl;

cout << "CGPA: " << cgpa << endl;

cout << "Marks: " << marks << endl;

cout << "Age: " << age << endl;

};

int main() {

Student alice, bob;

alice.setValue(101, 3.8, 85, 20);

bob.setValue(102, 3.5, 78, 21);

cout << "Details of Alice:" << endl;

alice.display();

cout << endl;

cout << "Details of Bob:" << endl;


bob.display();

return 0;

4. #include <iostream>

using namespace std;

class Employee {

private:

string name;

int employeeID;

float monthlySalary;

public:

Employee(const std::string &n, int id, float salary) : name(n), employeeID(id),


monthlySalary(salary) {}

float calculateAnnualSalary() const {

return monthlySalary * 12;


}

void displayDetails() const {

cout << "Name: " << name << endl;

cout << "Employee ID: " << employeeID << endl;

cout << "Monthly Salary: $" << monthlySalary << endl;

cout << "Annual Salary: $" << calculateAnnualSalary() << endl;

};

int main() {

Employee emp("Polok", 1001, 5000.0);

emp.displayDetails();

return 0;

You might also like