Course: CSE225L Assessment: Lab 1 Section:5 NSU ID:2211450042 Name: Tawsif Abdul Kadir // Task-1 Codes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

North South University - Spring 2023

Course: CSE225L Assessment: Lab 1

Section:5 NSU ID:2211450042 Name: Tawsif Abdul Kadir

// Task-1 Codes

//Task-2Codes

N.B. Do not make any changes in the format of that template. Page 1
// Task-3 Codes

// Online C++ compiler to run C++ program online


#include <iostream>

using namespace std;

int main() {
// Write C++ code here
int rows,starting_point=0,total_size=0,size;
cout << "Enter the number of rows: ";
cin >> rows;
int *columns = new int[rows];
for(int i=0;i<rows;i++){
cout << "Enter the size of row " << (i+1) << ": ";
cin >> size;
total_size+=size;
*(columns+i) = size;
}
int *arr = new int[total_size];
for(int row=0;row<rows;row++){
for(int column =0;column<*(columns+row);column++){
cout << "Enter element for row " << (row+1) << " and column " <<
(column+1) << ": ";
cin >> *(arr+starting_point+column);
}
starting_point+=*(columns+row);
}
starting_point=0;
for(int row=0;row<rows;row++){

N.B. Do not make any changes in the format of that template. Page 2
for(int column =0;column<*(columns+row);column++){
// cout << "Enter element for row " << (row+1) << " and column " <<
(column+1) << ": ";
cout << *(arr+starting_point+column) << " ";
}
starting_point+=*(columns+row);
cout << endl;
}
delete[] arr;
delete[] columns;
return 0;
}

N.B. Do not make any changes in the format of that template. Page 3

You might also like