Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Sum of diagonals #8102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Ctrl-apk
Copy link

Problem

Adding the diagonal elements(Both primary and secondary)

Solution

  1. A simple matrix will be taken as input from the user

  2. Method calculateSum takes a simple 2D array as input in which
    a)it calculates sum of primary diagonal and secondary diagonal.
    b)If matrix is of odd dimensions,the center element is subtracted from the sum because it gets counted twice.

  3. Output will be sum of both diagonals printed.

@Ctrl-apk
Copy link
Author

@Ctrl-apk Please Star ⭐️ the repo to earn 'hacktober-accepted' label for the event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant