Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will do a number of C programming exercises. Matrix multiplication (matrixmul.c): Given an n x k matrix A and an k

In this assignment, you will do a number of C programming exercises.

Matrix multiplication (matrixmul.c): Given an n x k matrix A and an k x m matrix B, with 1n,m,k300, write a C program that computes the matrix product C=AB. All entries in matrices A and B are integers with abolute value less than 1000, so you don't need to worry about overflow. If matrices A and B do not have the right dimensions to be multiplied, the product matrix C should have its number of rows and columns both set to zero. Input/Output: please use scanf and printf to handle the data input and output. Input format: Line 1: Two space-separated integers, n and k. Line 2 to n+1: line i+1 contains k space-separated integers: row i of matrix A. Line n+2: Two space-separated integers, k and m. Line n+3 to n+k+4: Line i+n+3 contains m space-separated integers: row i of matrix B. Sample Input:

3 2 1 1 1 2 -4 0 2 3 1 2 1 3 2 1 

Output format: Line 1: two space-separated n and m, the dimension of matrix C. Line 2 to m+1: Line i+1 contains m space-separated integers: row i of matrix C. Sample Output:

3 3 4 4 2 7 6 3 -4 -8 -4 

Transposition Cipher (encrypt.c): A very simple transposition cipher encrypt(S) can be described by the following rule:

If the length of S is 1 or 2, then encrypt(S) is S.

If S is a string of N characters s1 s2...sN and k=N/2, then enc(S)=encrypt(sksk-1...s2s1)+encrypt(sNsN-1...sk+1) where + indicates string cancatenation. For example, encrypt("OK")="OK" and encrypt("12345678")="34127856".

Write a program to implement this cipher, given an arbitary text string from keyboard, up to 8192 characters. It's better to write a separate encryption function, similar to the following:

char* encrypt(char *string, size_t length) { // you fill this out } 

Input Format: an abitary string (with the length up to 8192 characters). Sample Input: Test early and often! Output Format Line 1: One integer: the toal number of characters in the string. Line 2: The enciphered string. Sample Output:

21 aeyrleT sttf!enn aod 

III. Submission:

Each student submits one copy of the source code: matrixmul.c and encrypt.c.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago