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

Programming Exercises

Write a program to calculate the eigenvalues and eigenvectors of a given matrix.

Medium

Problem Statement

Write a program to calculate the eigenvalues and eigenvectors of a given matrix.

Sample Input

Matrix: 
 [,1] [,2]
[1,] 4 2
[2,] 1 3

Sample Output

[1] "Eigenvalues:"
[1] 5 2
[1] "Eigenvectors:"
          [,1]       [,2]
[1,] 0.7071068 -0.4472136
[2,] 0.7071068  0.8944272

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure matrix <- # Create the matrix eigen_result <- # Calculate eigenvalues and eigenvectors print(eigen_result)
Log in or sign up to run or submit your code.Log inSign up
Input
Matrix: 
 [,1] [,2]
[1,] 4 2
[2,] 1 3
Expected Output
[1] "Eigenvalues:"
[1] 5 2
[1] "Eigenvectors:"
          [,1]       [,2]
[1,] 0.7071068 -0.4472136
[2,] 0.7071068  0.8944272