QuestionQuestion

Write a single makefile to compile all your programs. Write a document to describe or explain how you designed and solved each problem briefly. Put all your codes, makefile and document into a zip file.

1. Input from the command line two positive integers p and q between 1 and 10 inclusive. Generate two random matrices A and B with elements of type double. A should be a p by q matrix and B should be a q by p matrix. Output the two matrix products AB and BA. Print all four matrices A, B, AB and BA to standard output with two digits after the decimal point. Write both a C version and a C++ version program for this problem. In the C version design a struct for the matrix. In the C++ version design a class for the matrix. You need to include the two dimension sizes (number of rows and columns) as member variables and make the storage for matrix elements dynamically allocated.

2. Convert the gcd.c into a C++ program. You need to design a suitable class.

3. Convert testShape.cpp into a C program. You need to design suitable structs.

4. Write a C or C++ program to input a hexadecimal number from the command line and output the equivalent binary number to the standard output. Note that both upper case A~F and lower case a~f are allowed in the hexadecimal number. (Example: input 123 should output 100100011 because 12316=29110=1001000112 ; input a4B should output 101001001011 because a4B16=263510=1010010010112)

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include <iostream>
using namespace std;

class calculation{
private:
public:
    calculation(){
      
    };
    int gcd(int x, int y){
       int t;
       int a = x;
       int b = y;

       while (b != 0) {
          t = b;
          b = a % b;
          a = t;
       }
       return a;
    };
    int lcm(int x, int y){
       int gcd = this->gcd(x, y);
       return x * y / gcd;
    };
};...
$55.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats