OOP Chapter 4 Solve
Programming Exercise 4.1 :
#include <iostream>
using namespace std;
int main()
{
int m,n;
cout <<
"Enter ROW 'M' of the matrix: ";
cin >> m;
cout <<
"Enter Column 'N' of the matrix: ";
cin >> n;
int ar[m][n];
cout <<
"Enter Your Matrix: " << endl << endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cin
>> ar[i][j];
}
}
cout <<
endl << endl << "Your Entered Matrix Is : " << endl
<< endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cout
<< ar[i][j] << "
";
}
cout
<< endl;
}
return 0;
}
Programming Exercise 4.2 :
#include <iostream>
using namespace std;
void show(int m,int n);
int main()
{
int m,n;
cout <<
"Enter ROW 'M' of the matrix: ";
cin >> m;
cout <<
"Enter Column 'N' of the matrix: ";
cin >> n;
show(m,n);
return 0;
}
void show(int m,int n)
{
int ar[m][n];
cout <<
"Enter Your Matrix: " << endl << endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cin
>> ar[i][j];
}
}
cout <<
endl << endl << "Your Entered Matrix Is : " << endl
<< endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cout
<< ar[i][j] << "
";
}
cout
<< endl;
}
}
Programming Exercise 4.3 :
#include <iostream>
using namespace std;
void show(int n,int m=2);
int main()
{
int n;
cout <<
"Enter Column 'N' of the matrix: ";
cin >> n;
show(n);
return 0;
}
void show(int n,int m)
{
int ar[m][n];
cout <<
"Enter Your Matrix: " << endl << endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cin >> ar[i][j];
}
}
cout <<
endl << endl << "Your Entered Matrix Is : " << endl
<< endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cout
<< ar[i][j] << "
";
}
cout
<< endl;
}
}
Programming Exercise 4.4 :
#include <iostream>
using namespace std;
void show(int n,int m=2);
void show(int n,short int m);
int main()
{
int n;
cout <<
"Enter Column 'N' of the matrix: ";
cin >> n;
show(n);
return 0;
}
void show(int n,int m)
{
int ar[m][n];
cout <<
"Enter Your Matrix: " << endl << endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cin
>> ar[i][j];
}
}
cout <<
endl << endl << "Your Entered Matrix Is : " << endl
<< endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cout
<< ar[i][j] << "
";
}
cout
<< endl;
}
}
void show(int n,short int m)
{
int ar[m][n];
cout <<
"Enter Your Matrix: " << endl << endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cin
>> ar[i][j];
}
}
cout <<
endl << endl << "Your Entered Matrix Is : " << endl
<< endl;
for(int
i=0;i<m;i++)
{
for(int
j=0;j<n;j++)
{
cout
<< ar[i][j] << "
";
}
cout
<< endl;
}
}
Programming
Exercise 4.5 :
#include <iostream>
using namespace std;
#define CHECK(a,b,c){if(a>b){if(a>c){cout <<
"A Large";}else{cout << "C Large";}}else
{if(b>c){cout << "B large"; }else{cout << "C
large";}}}
int main()
{
int c,d,e;
cout <<
"Enter Three Numbers: " << endl;
cin >> c
>> d >> e;
CHECK(c,d,e);
return 0;
}
Programming
Exercise 4.6 :
#include <iostream>
using namespace std;
void check(int a,int b,int c)
{
if(a>b)
{
if(a>c)
{
cout
<< "A Large";
}
else
{
cout
<< "C Large";
}
}
else
{
if(b>c)
{
cout
<< "B large";
}
else
{
cout
<< "C large";
}
}
}
int main()
{
int c,d,e;
cout <<
"Enter Three Numbers: " << endl;
cin >> c
>> d >> e;
check(c,d,e);
return 0;
}
Programming
Exercise 4.6 :
No comments:
Post a Comment