Find the number NUM of non-zero elements in a square matrix | C Language | IndianTechnoEra - IndianTechnoEra
Latest update Android YouTube

Find the number NUM of non-zero elements in a square matrix | C Language | IndianTechnoEra

Let A be an n*n square matrix array. Write a module which a) Find the number NUM of non-zero elements in A.
Admin

 

Let A be an n*n square matrix array.   Find the number NUM of non-zero elements in A.

#include<stdio.h>

#include<conio.h>

int main()

{

int a[10][10], i,j, N, nonzero=0;

printf("Enter the size of sqare matrix (max 10x10): ",N);

scanf("%d", &N);

printf("Enter the elements of %dx%d matrix:\n" ,N,N);

for(i=0;i<N;i++)

{

for(j=0;j<N;j++)

{

printf("Enter elements of a[%d[%d]: ",i,j);

scanf("%d", &a[i][j]);

}

}

for(i=0;i<N;i++)

{

for(j=0;j<N;j++)

{

if(a[i][j] !=0)

nonzero++;

}

}

printf("\nNo of non-zero emements: %d",nonzero);

        getch();

}




Let A be an n*n square matrix array. Write a module which

Find the number NUM of non-zero elements in A.


Post a Comment

Feel free to ask your query...
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.