Previous Next
0 / 21
Module DEMO-32-109DEMO-C-32

Scalar Multiplication

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program to multiply every element of a matrix by a scalar value K. Input is Matrix followed by K.

Constraints

1 <= N, M <= 10. Integers within standard range.

Input Format

Input: Dimensions N M followed by the matrix elements.

Output Format

Output: The formatted result as specified.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3 3
-3 35 4
14 13 -2
6 34 47
3
-9 105 12
42 39 -6
18 102 141
Multiplied all elements by 3.
Sample #2
Public sample
3 5
-3 -3 12 2 14
38 3 17 13 -5
38 19 -3 42 19
1
-3 -3 12 2 14
38 3 17 13 -5
38 19 -3 42 19
Multiplied all elements by 1.
Sample #3
Public sample
2 3
19 -10 25
40 37 15
3
57 -30 75
120 111 45
Multiplied all elements by 3.
Sample #4
Public sample
3 3
-7 16 -6
-8 29 -6
29 24 22
8
-56 128 -48
-64 232 -48
232 192 176
Multiplied all elements by 8.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings