-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsparseMatrix.cpp
More file actions
36 lines (36 loc) · 887 Bytes
/
sparseMatrix.cpp
File metadata and controls
36 lines (36 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
int n,i,j,r,c,a[100][100];
printf("Enter the number of rows and columns\n");
scanf("%d %d",&r,&c);
printf("Enter the values\n");
for(i=0;i<r;i++)
for(j=0;j<c;j++){
scanf("%d",&a[i][j]);
}
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
if(a[i][j]!=0){
printf("\n for non-zero element, row no = %d\n column no =%d\nvalue=%d\n",i+1,j+1,a[i][j]);
}
}
printf("\n");
printf("enter the element to be searched\n");
scanf("%d",&n);
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{
if(a[i][j]=n){
printf("The element %d is present at row=%d and col=%d\n",a[i][j],i+1,j+1);
exit(0);
}
printf("ELement is not here");
getch();
}
getch();
return 0;
}