You are on page 1of 63

1.

AIM:
To calculate the average of 4 numbers.

PROGRAM:
#include <stdio.h>
main()
{
int a,b,c,d;

float avg;
printf("Enter 4 numbers:");
scanf("%d %d %d %d",&a,&b,&c,&d);
avg=(a+b+c+d)/4;
printf("The average is %f",avg);

}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
2.AIM:
Write a program to convert feet to cm.

PROGRAM:
#include <stdio.h>
main()
{
int f,l;

printf("Enter the length in feet:");


scanf("%d", &f);
l=f * 30;
printf("Length in cms is %d", l);
}

OUTPUT:

RESULT:

The program has been executed and output has been verified successfully.
3.AIM:
Write a program to calculate the area of a rectangle.

PROGRAM:
#include <stdio.h>
main()
{
int length,breadth,area;

printf("Enter the length of the rectangle:");


scanf("%d", &length);
printf("\nEnter the breadth of the rectangle:");
scanf("%d", &breadth);
area = length * breadth;

printf("\nThe area of rectangle is %d", area);


}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
4.AIM:
Write a program to determine the roots of a quadratic equation.

PROGRAM:
#include <stdio.h>
#include <math.h>
main()
{

int a, b, c, d, r1, r2 ;
printf("Enter the values for a,b and c:") ;
scanf("%d %d %d", &a, &b, &c) ;
d = b * b - 4 * a * c;
if (d < 0)

{
printf("The Roots does not exist") ;
}
else
{
r1 = (- b - sqrt(d)) / 2 * a ;
r2 = (- b + sqrt(d)) / 2 * a ;
printf("The roots are %d and %d", root1, root2);
}
}

OUTPUT:

RESULT: The program has been executed and output has been verified successfully.
5.AIM:
Write a program to find the sum and product of three floating numbers.

PROGRAM:
#include <stdio.h>
main()
{
float a,b,c,sum=0,product;

printf("Enter three decimal numbers:");


scanf("%f %f %f", &a, &b, &c);
sum = a+b+c;
product = a*b*c;
printf("The sum of numbers is %.3f",sum);

printf("\nThe product of numbers is %.3f",product);


}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
6.AIM:
Write a program to print the corresponding ASCII values of the alphabet.

PROGRAM:
#include <stdio.h>
main()
{
char a;

printf("Enter a letter:");
scanf("%c", &a);
printf("The ASCII value of %c is %d",a, a);
}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
7.AIM:
Write a program to determine the height and time taken by an object

PROGRAM:
#include <stdio.h>
main()
{
float u,t,s;

Printf(“Enter the initial velocity:”);


Scanf(“%f”,&u);
s=(u*u)/(2*10);
t=u/10;
printf(“The time taken is %f”,t);

printf(“The maximum height reached is %f”,s);


}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
8.AIM:
Write a program to determine the size of different datatypes.

PROGRAM:
#include <stdio.h>
main()
{
printf("Size of different datatypes \n");

printf("\nSize of int is: %d bytes\n",sizeof(int));


printf("\nSize of float is : %d bytes\n", sizeof(float));
printf("\nSize of char is : %d bytes\n", sizeof(char));
printf("\nSize of long int is : %d bytes\n", sizeof(long int));
printf("\nSize of short int is : %d bytes\n", sizeof(short int));

printf("\nSize of double is : %d bytes\n", sizeof(double));


printf("\nSize of long double is : %d bytes\n", sizeof(long double));
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
8.AIM:
Write a program to swap two numbers.

PROGRAM:
#include <stdio.h>
main()
{
int a, b;

printf("Enter the two numbers:");


scanf("%d %d", &a, &b);
a = a + b;
b = a - b;
a = a - b;

printf("The swapped numbers is %d & %d", a,b);


}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
9.AIM:
Write a program to convert the number of days into years months weeks and days.

PROGRAM:
#include<stdio.h>

main()

int y,w,da,dy,m;

printf("Enter the total number of days: \n");

scanf("%d",&da);

y=da/365;

da=da-(365*y);

m=da/30;

da=da-(m*30);

w=da/7;

da=da-(w*7);

dy=da;

printf("The total number of years: %d \n",y);

printf("The total number of months: %d \n",m);

printf("The total number of weeks: %d \n",w);

printf("The total number of days: %d \n",dy);

OUTPUT:

RESULT: The program has been executed and output has been verified successfully.
10.AIM:
Write a program to check if the number is divisible by 5 and if divisible by 7 ,if it is divisible by
11.

PROGRAM:

#include<stdio.h>
main()
{
int num;
printf("Enter the number : \t");

scanf("%d",&num);
{
if(num%5==0)
printf("It's multiple by 5\n");
else

printf("It's not divisible by 5\n");


}
if(num%7==0)
{
if(num%11==0)

printf("It's divisible by by 7 & 11\n");


else
printf("It's divisible by 7 not by 11\n");
}
else

printf("The number is not divisible by 7\n");


OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
12.AIM:
Write a program to find whether the given character is a consonant or a vowel

PROGRAM:
#include <stdio.h>
main()
{
char l ;

printf("Enter a letter:");
scanf("%c", &l);
if ((l=='a') || (l=='A') || (l=='e') || (l=='E') || (l=='i') || (l=='I') || (l=='o') || (l=='O') || (l=='u') ||
(l=='U'))
printf("This letter is a vowel");
else
printf("Consonant");

}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
13.AIM:
Write a program to accept the a,b,c of quadractic equation and it does not hold the condition.

PROGRAM:
#include <stdio.h>
#include <math.h>
main()
{

float a,b,c,x,y,z;
printf("Enter the values of a,b,c:");
scanf("%f %f %f",&a,&b,&c);
if((a+c>b)&&(a+c>0))
{

z=sqrt((b*b)-(4*a*c));
x=(-b+z)/(2*a);
y=(-b-z)/(2*a);
printf("The roots of the quadractic equations are %.2f and %.2f",x,y);
}
else{
printf("WRONG INPUT");
}
}
OUTPUT:

RESULT: The program has been executed and output has been verified successfully.
14.AIM:
Write a program to check the condition of traigle.

PROGRAM:
#include <stdio.h>
main()
{
float a,b,c;

printf("\n Enter value for Side-1 : ");


scanf("%f",&a);
printf("\n Enter value for Side-2 : ");
scanf("%f",&b);
printf("\n Enter value for Side-3 : ");

scanf("%f",&c);

if(a<(b+c)&&b<(a+c)&&c<(a+b))
{
printf("\n RESULT: It is a Triangle.");
if(a==b&&a==c&&b==c)
printf("\n It is a Equilateral Triangle.");
else if(a==b||a==c||b==c)
printf("\n It is a Isosceles Triangle.");
else if((a*a)==(b*b)+(c*c)||(b*b)==(a*a)+(c*c)||(c*c)==(a*a)+(b*b))

printf("\n It is a Right-angle Triangle.");


else if(a!=b&&a!=c&&b!=c)
printf("\n It is a Scalene Triangle.");
}
else
printf("\n RESULT: This Triangle is NOT possible.");
}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
15.AIM:
Write a program to check the increment and decrement values.

PROGRAM:
#include <stdio.h>
main()
{
int x, y, z;

printf("\tEnter the values of x and z ");


scanf("%d %d",&x,&z);
y = x++ + ++x;
printf("\nThe value of y is %d",y);
y= ++x + ++x;

printf("\nThe value of y is %d",y);


y= ++x + ++x + ++x;
printf("\nThe value of y is %d",y);
y = x>z;
printf("\nThe value of y is %d",y);
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
16.AIM:
Write a program to accept grade and declare the equivalent description.

PROGRAM:
#include <stdio.h>
main()
{
char grade=0;

printf("Enter the grade");


scanf("%c",&grade);
switch(grade=toupper(grade))
{
case'E':

printf("Excellent");
break;
case'V':
printf("very good");
break;
case'G':
printf("Good");
break;
case'F':
printf("Fail");

break;
}
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
17.AIM:
Write a program to any day in integer and display name in word
PROGRAM:

#include<stdio.h>
main()
{
int day;
printf("Enter the day:");

scanf("%d",&day);
switch(day)
{
case 1:
printf("Monday");

break;
case 2:
printf("Tuesday");
break;
case 3:
printf("Wednesday");
break;
case 4:
printf("Thursday");
break;

case 5:
printf("Friday");
break;
case 6:
printf("Saturday");
break;
case 7:

printf("Sunday");
break;

}
}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
18.AIM:
Write a program to any month number in integer and display no. Of days
PROGRAM:

#include<stdio.h>
main()
{
int monno;
printf("Input Month No : ");

scanf("%d",&monno);
switch(monno)
{
case 1:
case 3:

case 5:
case 7:
case 8:
case 10:
case 12:
printf("Month have 31 days. \n");
break;
case 2:
printf("The 2nd month is a February and have 28 days. \n");
printf("in leap year The February month Have 29 days.\n");

break;
case 4:
case 6:
case 9:
case 11:
printf("Month have 30 days. \n");
break;

default:
printf("invalid Month number.\nPlease try again ....\n");
break;
}
}

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
19.AIM:
Write a program to read gender and print the corresponding gender.
PROGRAM:

#include <stdio.h>
int main()
{
char gender;
printf("Enter gender (M/m or F/f): ");
scanf("%c",&gender);

switch(gender)
{
case 'M':
case 'm':
printf("Male");
break;
case 'F':
case 'f':
printf("Female");
break;
default:
printf("Unspecified Gender\n");
}
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
20.AIM:
Write a program to check whether a character is vowel or consonant
PROGRAM:

#include <stdio.h>
int main()
{
char ch;
printf("Enter any alphabet: ");
scanf("%c", &ch);

switch(ch)
{
case 'a':
case 'e':
case 'i':

case 'o':
case 'u':
case 'A':
case 'E':
case 'I':

case 'O':
case 'U':
printf("Vowel");
break;
default:

printf("Consonant");
}
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
21.AIM:
Write a program to check whether a number is odd or even.
PROGRAM:

#include<stdio.h>
main()
{
int a;
printf("Enter a number :");

scanf("%d",&a);
switch(a%2)
{
case 0:
printf("%d is even",a);

break;
case 1:
printf("%d is odd",a);
break;
}
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
22.AIM:
Write a program that will read two integers and perform basic operations.
PROGRAM:

#include <stdio.h>
main()
{
int num1,num2;
float result;

char ch;
printf("Enter first number: ");
scanf("%d",&num1);
printf("Enter second number: ");
scanf("%d",&num2);

printf("Choose operation to perform (+,-,*,/,%): ");


scanf(" %c",&ch);
result=0;
switch(ch)
{
case '+':
result=num1+num2;
break;
case '-':
result=num1-num2;

break;
case '*':
result=num1*num2;
break;
case '/':
result=(float)num1/(float)num2;
break;

case '%':
result=num1%num2;
break;
default:

printf("Invalid operation.\n");
}
printf("Result: %d %c %d = %f\n",num1,ch,num2,result);
}
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
23.AIM:
Write a multiplication table getting input from the user.
PROGRAM:

#include <stdio.h>
main()
{
int n,i ;
printf("Enter an integer: ");

scanf("%d",&n);
for (i = 1; i <= 10; i++)
{
printf("%d * %d = %d \n", i, n, i*n);
}

}
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
24.AIM:
Write a program to read numbers from keyboard &find their sum &average
PROGRAM:

#include <stdio.h>
main()
{
int num, sum = 0,i;
float avg;

printf("Please Enter the 10 Numbers\n");


for(i = 1; i <= 10; i++)
{
printf("Number %d = ", i);
scanf("%d", &num);

sum = sum + num;


}
avg = sum / 10;
printf("\nThe Sum of 10 Numbers = %d", sum);
printf("\nThe Average of 10 Numbers = %f\n", avg);
}
OUTPUT:

RESULT: The program has been executed and output has been verified successfully
25.AIM:
Write a program to display the cube of the given number upto given integer.
PROGRAM:

#include <stdio.h>
main()
{
int i,n;
printf("Input number of terms : ");

scanf("%d", &n);
for(i=1;i<=n;i++)
{
printf("Number is : %d and cube of the %d is :%d \n",i,i, (i*i*i));
}

}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
26.AIM:
Write a program to display the multiplication table of 15.
PROGRAM:

#include <stdio.h>

main()

int n=15,i ;

printf("Enter an integer: ");

for (i = 1; i <= 10; i++)

printf("%d * %d = %d \n", i, n, i*n);

OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
27.AIM:
Write a program to display the multiplication table vertically 1 to n
PROGRAM:

#include <stdio.h>

main()

int j,i,n;

printf("Input upto the table number starting from 1 : ");

scanf("%d",&n);

printf("Multiplication table from 1 to %d \n",n);

for(i=1;i<=10;i++)

for(j=1;j<=n;j++)

printf("\t%dx%d = %d, ",j,i,i*j);

printf("\n");

}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
28.AIM:
Write a program to display the odd natural numbers and sum.
PROGRAM:

#include <stdio.h>
main()
{
int i,n,sum=0;

printf("Input number of terms : ");


scanf("%d",&n);
printf("\nThe odd numbers are :");
for(i=1;i<=n;i++)
{

printf("%d ",2*i-1);
sum+=2*i-1;
}
printf("\nThe Sum of odd Natural Number upto %d terms : %d \n",n,sum);
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
29.AIM:
Write a program to display the given number is prime or not.
PROGRAM:

#include<stdio.h>
main()
{
int n, i, c = 0;
printf("Enter any number n:");

scanf("%d", &n);

for (i = 1; i <= n; i++)


{
if (n % i == 0)

{
c++;
}
}

if (c == 2)
{
printf("%d is a Prime number",n);
}
else

{
printf("%d is not a Prime number",n);
}
}
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
30.AIM:
Write a program to display the sequence
PROGRAM:

#include<stdio.h>
main()
{
int i,j;
for(i=1;i<=5;i++)

{
for(j=1;j<=5;j++)
printf("\t*");
printf("\n");
}

}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
31.AIM:
Write a program to display the fibanocci series.
PROGRAM:

#include <stdio.h>
main()
{
int i, n, t1 = 0, t2 = 1, t3= t1 + t2;
printf("Enter the number of terms: ");

scanf("%d", &n);
printf("Fibonacci Series: %d, %d, ", t1, t2);
for (i = 3; i <= n; i++)
{
printf("%d, ", t3);

t1 = t2;
t2 = t3;
t3 = t1 + t2;
}
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully
32.AIM:
Write a program If, 1 ≤ n ≤ 9, print the lowercase English word corresponding to the number
PROGRAM:

#include <stdio.h>
int main()
{
int n;
printf("Enter the number:");

scanf("%d",&n);
if (n == 1) {
printf("one\n");
} else if (n == 2) {
printf("two\n");

} else if (n == 3) {
printf("three\n");
} else if (n == 4) {
printf("four\n");
} else if (n == 5) {
printf("five\n");
} else if (n == 6) {
printf("six\n");
} else if (n == 7) {
printf("seven\n");

} else if (n == 8) {
printf("eight\n");
} else if (n == 9) {
printf("nine\n");
} else {
printf("Greater than 9\n");
}

}
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
33.AIM:
Write a program to calculate and tabulate the first n prime numbers.
PROGRAM:

#include<stdio.h>
int main()
{
int n,i=1,j=0,m;
printf("Enter the no. of terms :");

scanf("%d",&n);
while(j<n)
{
for(m=2;m<i;m++)
{

if(i%m==0)
break;
}
if(m==i)
{
printf("%d\t",i);
j++;
}
i++;
}

}
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
34.AIM:
Write a program to separate the digits of a five digit number &apply %operator.
PROGRAM:

#include<stdio.h>
int main()
{
int n;
printf( "Input a five digit number: " );

scanf("%d", &n);
printf( "\nOutput: " );
printf("%d ", (n/10000));
n = n - ((n/10000)*10000);
printf("%d ", (n/1000));

n = n - ((n/1000)*1000);

printf("%d ", (n/100));


n = n - ((n/100)*100);

printf("%d ", (n/10));


n = n - ((n/10)*10);

printf("%d\n", (n%10));

return 0;
}
OUTPUT:
RESULT:
The program has been executed and output has been verified successfully
35.AIM:
Write a program to Insert an element in an array.

PROGRAM:
#include<stdio.h>
main()
{
int a[50],i,n,pos,val;

printf("Enter the number of elemts:");


scanf("%d",&n);
printf("\nEnter the %d elements:\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);

printf("\nEnter the position:");


scanf("%d",&pos);
printf("\nEnter the value to be added:");
scanf("%d",&val);
for(i=n-1;i>=pos-1;i--)

a[i+1]=a[i];
a[pos-1]=val;
printf("\narray after adding");
for(i=0;i<=n;i++)
printf("\n%d",a[i]);
}

OUTPUT:
RESULT:
The program has been executed and output has been verified successfully
36.AIM:
Write a program to Delete an element from the array

PROGRAM:
#include <stdio.h>
main()
{
int array[100], pos, i, n;

printf("Enter number of elements in array\n");


scanf("%d", &n);
printf("Enter %d elements\n", n);
for ( i = 0 ; i< n ; i++ )
scanf("%d", &array[i]);

printf("Enter the location where you wish to delete element\n");


scanf("%d", &pos);
if ( pos >= n+1 )
printf("Deletion not possible.\n");
else

{
for ( i = pos - 1 ; i < n - 1 ; i++ )
array[i] = array[i+1];
printf("Resultant array is\n");

for( i = 0 ; i < n - 1 ; i++ )

printf("%d\n", array[i]);
}
}
OUTPUT:
RESULT:
The program has been executed and output has been verified successfully
37.AIM:
Write a program to Swap two elements in an array

PROGRAM:
#include<stdio.h>
int main() {
int a[10],b[10],c[10],i;
printf("Enter First array\t");

for (i=0;i<10;i++)
scanf("%d",&a[i]);
printf("\nEnter Second array\t");
for (i=0;i<10;i++)
scanf("%d",&b[i]);

printf("Arrays before swapping");


printf("\nFirst array\t");
for (i=0;i<10;i++) {
printf("\t %d",a[i]);
}

printf("\nSecond array->");
for (i=0;i<10;i++) {
printf("\t%d",b[i]);
}
for (i=0;i<10;i++) {
c[i]=a[i];
a[i]=b[i];

b[i]=c[i];
}
printf("\nArrays after swapping");
printf("\nFirst array->");
for (i=0;i<10;i++) {

printf("\t%d",a[i]);
}
printf("\nSecond array->");
for (i=0;i<10;i++) {
printf("\t%d",b[i]);

}
}
OUTPUT:
RESULT:
The program has been executed and output has been verified successfully

38.AIM:
Write a program in C to count a total number of duplicate elementsin an array.
PROGRAM:
#include <stdio.h>
void main()

{
int arr1[100];
int arr2[100];
int arr3[100];
int n,mm=1,ctr=0;
int i, j;
printf("\n\nCount total number of duplicate elements in an array:\n");
printf("Input the number of elements to be stored in the array :");

scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{
printf("element - %d : ",i);

scanf("%d",&arr1[i]);
}
for(i=0;i<n; i++)
{
arr2[i]=arr1[i];

arr3[i]=0;
}
for(i=0;i<n; i++)
{
for(j=0;j<n;j++)
{
if(arr1[i]==arr2[j])
{
arr3[j]=mm;
mm++;

}
}
mm=1;
}
for(i=0; i<n; i++)
{
if(arr3[i]==2)

{
ctr++;
}
}
printf("The total number of duplicate elements found in the array is: %d \n", ctr);

printf("\n\n"); }
OUTPUT:

RESULT:

The program has been executed and output has been verified successfully
39.AIM:
Write a program in C to print all unique elements in an array
PROGRAM:
#include <stdio.h>

int main()
{
int arr1[100], n,ctr=0;
int i, j, k;
printf("Input the number of elements to be stored in the array: ");

scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)
{

printf("element - %d : ",i);
scanf("%d",&arr1[i]);
}
printf("\nThe unique elements found in the array are: \n");
for(i=0; i<n; i++)

{
ctr=0;
for(j=0,k=n; j<k+1; j++)
{
if (i!=j)

{
if(arr1[i]==arr1[j])
{
ctr++;
}
}
}
if(ctr==0)
{
printf("%d ",arr1[i]);

}
}
printf("\n\n");
}
OUTPUT:

RESULT:
The program has been executed and output has been verified successfully.
40.AIM:

Write a program in C to find the maximum and minimum elementin an array.


PROGRAM:
#include<stdio.h>
main()
{

int a[50],i,n,mx,mn;
printf("Enter the number of elements:");
scanf("%d",&n);
printf("\nEnter the %d elements:\n",n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
mx=a[0];

mn=a[0];
for(i=1;i<n;i++)
{
if(a[i]>mx)
{

mx=a[i];
}
if(a[i]<mn)
{
mn=a[i];

}
}
printf("\nmaximum is %d",mx);
printf("\nminimum is %d",mn);
}
OUTPUT:
RESULT:
The program has been executed and output has been verified successfully.
41.AIM:
Write a program in C to separate odd and even integers in separate arrays

PROGRAM:
#include <stdio.h>
void main()
{
int arr1[10], arr2[10], arr3[10];

int i,j=0,k=0,n;
printf("Input the number of elements to be stored in the array :");
scanf("%d",&n);
printf("Input %d elements in the array :\n",n);
for(i=0;i<n;i++)

{
printf("element - %d : ",i);
scanf("%d",&arr1[i]);
}

for(i=0;i<n;i++)
{
if (arr1[i]%2 == 0)
{
arr2[j] = arr1[i];

j++;
}
Else {
arr3[k] = arr1[i];
k++;
}
}

printf("\nThe Even elements are : \n");


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

{
printf("%d ",arr2[i]);
}
printf("\nThe Odd elements are :\n");
for(i=0;i<k;i++)
{
printf("%d ", arr3[i]);

}
printf("\n\n");
}
OUTPUT:

RESULT: The program has been executed and output has been verified successfully.
42.AIM:
Write a program in C to accept a matrix and determine whether it is a sparse matrix.
PROGRAM:
#include <stdio.h>

void main ()
{
int arr1[10][10];
int i,j,r,c;
int ctr=0;

printf("Input the number of rows of the matrix : ");


scanf("%d", &r);
printf("Input the number of columns of the matrix : ");
scanf("%d", &c);

printf("Input elements in the first matrix :\n");


for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{

printf("element - [%d],[%d] : ",i,j);


scanf("%d",&arr1[i][j]);
if (arr1[i][j]==0)
{
++ctr;

}
}
}
if (ctr>((r*c)/2))
{
printf ("The given matrix is sparse matrix. \n");
}
else
printf ("The given matrix is not a sparse matrix.\n");

printf ("There are %d number of zeros in the matrix.\n\n",ctr);


}
OUTPUT:
RESULT:

The program has been executed and output has been verified successfully.

You might also like