0% found this document useful (0 votes)
9 views5 pages

Lab Task Submission Format

The document contains a series of C++ programming tasks focused on array manipulation. It includes code for calculating cube roots, subtracting and adding two-dimensional arrays, and finding the minimum and maximum values in an array. Each task prompts the user for input and displays the results accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Lab Task Submission Format

The document contains a series of C++ programming tasks focused on array manipulation. It includes code for calculating cube roots, subtracting and adding two-dimensional arrays, and finding the minimum and maximum values in an array. Each task prompts the user for input and displays the results accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

NAME: Hamza Iqbal

ID: FA24-BSCS-0128
LAB TASK NO: 10

Code Output

Question01:
#include<iostream>
using namespace std;
int main (){

int size;

cout<<"Enter the size of the array: ";


cin >> size ;

int array[size];
cout<<"Enter how many elements you
want a cube root of : ";
for(int i=0; i<size; i++){
cin >> array[i];}

int cube[size];
cout<<"The cube of the following number
are : ";
for(int i=0; i<size; i++){
cube[i]= array[i]*array[i]*array[i];
cout<<cube[i]<<" ";
}
cout<<endl;

Question02:

#include<iostream>
using namespace std;
int main (){

//declaring rows and cols


int rows, cols;
//input cols and rows
cout<<"Enter how many Rows you want ";
cin >> rows;
cout<<"Enter how many Columns you want ";
cin >> cols;
int subtract[rows][cols];

//store into arrays


int array1[rows][cols];
int array2[rows][cols];
//for first array
cout<<"Enter Elements for first array: ";
for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
cin>>array1[i][j];
}
}

//for second array


cout<<"Enter Elements for second array: ";
for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
cin>>array2[i][j];
}
}

//for subtracting array


for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
subtract[i][j]= array2[i][j]- array1[i]
[j];
}
}

//storing subtracting array


for(int i =0; i<rows; i++){
cout<<"[ ";
for(int j = 0; j<cols; j++){
cout<<subtract[i][j];
}
cout<<" ]";
cout<<endl;
}

Question03:
#include<iostream>
using namespace std;
int main (){

//declaring rows and cols


int rows, cols;
//input cols and rows
cout<<"Enter how many Rows you want ";
cin >> rows;
cout<<"Enter how many Columns you want ";
cin >> cols;
int add[rows][cols];

//store into arrays


int array1[rows][cols];
int array2[rows][cols];

//for frist array


cout<<"Enter Elements for first array: ";
for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
cin>>array1[i][j];
}
}

//for second array


cout<<"Enter Elements for second array: ";
for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
cin>>array2[i][j];
}
}

//for subtracting array


for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
add[i][j]= array2[i][j]+ array1[i][j];
}
}

//storing subtracting array


for(int i =0; i<rows; i++){
cout<<"[ ";
for(int j = 0; j<cols; j++){
cout<<subtract[i][j];
}
cout<<" ]";
cout<<endl;
}

Question04:
#include<iostream>
using namespace std;
int main (){

//declaring rows and cols


int rows, cols, min=2147483647,
max=-2147483647;//MAXUMIMUM VALUE FOR INTEGERS
//input cols and rows
cout<<"Enter how many Rows you want ";
cin >> rows;
cout<<"Enter how many Columns you want ";
cin >> cols;

//store into arrays


int array[rows][cols];

//for frist array


cout<<"Enter Elements for first array: ";
for(int i =0; i<rows; i++){
for(int j = 0; j<cols; j++){
cin>>array[i][j];
}
}
//calculating max and min

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


for(int j = 0; j<cols; j++){
if(array[i][j]<=min ){
min = array[i][j];
}
}
}

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


for(int j = 0; j<cols; j++){
if(array[i][j]>= max){
max = array[i][j];
}
}
}
cout<<"The maximum value is : "<<max<<endl;
cout<<"The minimum value is : "<<min;

Question05:

You might also like