Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to calculate the element-wise product of two matrices.

Medium

Problem Statement

Write a program to calculate the element-wise product of two matrices.

Sample Input

Matrix 1: 
 [,1] [,2]
[1,] 1 2
[2,] 3 4
Matrix 2: 
 [,1] [,2]
[1,] 5 6
[2,] 7 8

Sample Output

     [,1] [,2]
[1,]    5   21
[2,]   12   32

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure matrix1 <- # Create the first matrix matrix2 <- # Create the second matrix product <- # Perform element-wise multiplication print(product)
Log in or sign up to run or submit your code.Log inSign up
Input
Matrix 1: 
 [,1] [,2]
[1,] 1 2
[2,] 3 4
Matrix 2: 
 [,1] [,2]
[1,] 5 6
[2,] 7 8
Expected Output
     [,1] [,2]
[1,]    5   21
[2,]   12   32