C++programming code
#include
#include
main()
{
int m, n, c, d, first[10][10], second[10][10], sum[10][10];
cout << "enter the number of rows and columns of matrix ";
cin >> m >> n;
cout << "enter the elements of first matrix\n";
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
cin >> first[c][d];
cout << "enter the elements of second matrix\n";
for ( c = 0 ; c < m ;c++ )
for ( d = 0 ; d < n ; d++ )
cin >> second[c][d];
for ( c = 0 ; c < m ; c++ )
for ( d = 0 ; d < n ; d++ )
sum[c][d] = first[c][d] + second[c][d];
cout << "sum of entered matrices:-\n";
for ( c = 0 ; c < m ; c++ )
{
for ( d = 0 ; d < n ; d++ )
cout << sum[c][d] << "\t";
cout << endl;
}
return 0;
}
C++ programming code
#include
#include
main()
{
int n, max, num, c;
cout << "enter the number of random numbers you want ";
cin >> n;
cout << "enter the maximum value of random number ";
cin >> max;
cout << "random numbers from 0 to " << max << " are :-" << endl;
for ( c = 1 ; c <= n ; c++ )
{
num = random(max);
cout << num << endl;
}
return 0;
}
C++ programming code
#include
#include
class programming
{
private:
int variable;
public:
void input_value()
{
cout << "in function input_value, enter an integer\n";
cin >> variable;
}
void output_value()
{
cout << "variable entered is ";
cout << variable << "\n";
}
};
main()
{
programming object;
object.input_value();
object.output_value();
return 0;
}
No comments:
Post a Comment