Name Ayesha tahir
Assignment #4
Pf section R
L1s19bsse8006
Question no 1
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
int row= 2; int column = 2;
int** pointer = new int* [row];
for (int a = 0; a< row; ++a)
pointer[a] = new int[column];
int a; int b;
for (a= 0; a < row; a++)
for (b = 0; b< column; b++)
cin >> pointer[a][b];
for (a= 0; a< row; a++)
for (b= 0; b < column; b++)
if (a == b)
pointer[a][b] = 0;
for (a= 0; a< row; a++)
for (b= 0; b< column; b++)
cout << "x[" << a<< "][" << b<< "]=" << pointer[a][b] << endl;
cout << endl;
}
Question no 2
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
int row = 2, column = 2;
cout << "the square root of the numbers in the array " ;
cout<< endl;
int** pionter = new int* [row];
for (int x = 0; x< rows ++x)
Pointer[x] = new int[column];
int** poniter2= new int* [row];
for (int x = 0; x< row; ++x)
Poniter2[x] = new int[column];
int x;
int y;
for (x= 0; x < row; x++)
for (y= 0; y< column; y++)
cin >> pointer[x][y];
for (x= 0; x< row; x++)
for (y = 0; y< column; y++)
poniter2[x][y] = sqrt(pointer[x][y]);
cout << pointer[x][y] ;
cout<< endl;
}
Question no 3
#include <iostream>
using namespace std;
int arr(int array[], int number)
if (number== 1 || number == 0)
return 1;
if (array[number 1] < array[number - 2])
return 0;
return arr(array number- 1);
int main()
int array[] = { 20, 23, 23, 45, 78, 88 };
int number = sizeof(array) / sizeof(array[0]);
if (arr(array,number))
cout << " select the option yes or not”;
cout<<endl;
cout<<”the answer is “;
cout<<endl;
else
{
cout << "select the option not ";
cout<<endl;
}
Question no 4
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
Int rows = 4, column= 4;
int** pointer= new int* [rows];
for (int i = 0; i < r; ++i)
pointer[i] = new int[column];
int i;
int j;
Int thesum = 0;
for (i = 0; i < row;i++)
for (j = 0; j < column; j++)
cin >> pointer[i][j];
for (i = 0; i < row; i++)
for (j = 0; j < column; j++)
the sum += pointer[i][j];
cout << " the word summation in the array " << thesum ;
cout << endl;
for (i = 0; i < row; i++)
for (j = 0; j < column; j++)
cout <<pointer[i][j];
cout << endl;
}