Professional Documents
Culture Documents
SarvodayKelavaniSamaj, Rajkot
Sanchalit
Shree ManibhaiVirani& Smt. NavalbenVirani Science College
(Autonomous)
[ Re-accredited at ‘A’ level by NAAC & ‘STAR’ College by MST-DBT
Accredited at the G-AAA ‘A-1’ level by KCG Govt. of Gujarat
A College with Potential for Excellence by UGC]
YogidhamGurukul
DEPARTMENT OF MATHEMATICS
CERTIFICATE
This is to certify that experiments for the course
Course Code: 21UMTCC507
Core Practical: 5 Problem Solving using Programming
duly recorded and initiated in this Journal were performed to my
satisfaction by
Mr./ Miss. _____________________________________
of class
B.Sc. Semester -5 (Mathematics)
during the first term in the academic Year 2023 – 2024 in the
Computer laboratory.
His/her Roll No.: - ____________
Practical Given Performed
Programming in C 24
-1–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
B.Sc.Mathematics SEMESTER - 5
Core Practical: 5 Problem Solving using Programming
INDEX
Practical Page
Objective of Practical Date Signature
number No.
Write a program to find area of a circle
1 5
when radius is given.
-2–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Write a program that utilizes a UDF two
19 find prime numbers between two integers 30
entered through key-board.
-3–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
PROGRAMMINGwith
C
-4–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 1
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find area of a circle when radius is given. */
//PROGRAM CODE:-
/* OBJECTIVE:- Write a program to find area of a circle when radius is given. */
//PROGRAM CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{ float radius, area;
fflush(stdin); clrscr();
area = 3.1415*radius*radius;
/*OUTPUT*/
Sign of Lecturer:-_______________
-5–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 2
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find area of a Triangle when base and height
are given. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to find area of a Triangle when base and height
are given. */
#include<stdio.h>
#include<conio.h>
void main()
{ float base, height, area;
fflush(stdin); clrscr();
printf("\n\t Please enter the value of Base\t: ");
scanf("%f", &base);
printf("\n\t Please enter the value of Height\t: ");
scanf("%f", &height);
area = 0.5*base*height;
printf("\n\t Area of the triangle with base %f & height %f\t=\t%f\n", base, height, area);
} //main over //
/*OUTPUT*/
Area of the triangle with base 10.000000 & height 5.000000 = 25.000000
Area of the triangle with base 35.000000 & height 49.000000 = 857.500000
Sign of Lecturer:-_______________
Practical no :- 3
-6–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find value of one number raised to another
number. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to find value of one number raised to another
number. */
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{ float a, m, value;
fflush(stdin); clrscr();
printf("\n\t Please enter the value of Base number\t: ");
scanf("%f", &a);
printf("\n\t Please enter the value of power\t: ");
scanf("%f", &m);
} //main over //
/*OUTPUT*/
Sign of Lecturer:-_______________
-7–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :-4
/* Date :- - -2023 */
/* OBJECTIVE:-
Write a program to determine whether given number is an even or odd number. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to determine whether given number is an even or
odd number. */
#include<stdio.h>
#include<conio.h>
void main()
{ int no;
fflush(stdin); clrscr();
printf("\n\t Please enter an integer\t: ");
scanf("%d", &no);
if(no%2 == 0)
printf("\n\t %d is an EVEN number\n" , no);
else
printf("\n\t %d is an ODD number\n" , no);
getch(); return 0;
} //main over //
/*OUTPUT*/
Sign of Lecturer:-_______________
-8–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 5
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find largest of THREE given numbers. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to find largest of three given numbers. */
#include<stdio.h>
#include<conio.h>
void main()
{ float a, b, c;
fflush(stdin); clrscr();
printf("\n\t Please enter three real numbers\t: ");
scanf("%f%f%f", &a, &b, &c);
if(a>=b)
{
if(a>=c)
{printf("\n\t %f is a largest number \n ", a);}
else
{printf("\n\t %f is a largest number \n ", c);}
}
else
{
if(b>=c)
{printf("\n\t %f is a largest number \n ", b);}
else
{printf("\n\t %f is a largest number \n ", c);}
}
printf(“\n\n\n\n\n\n”); getch(); return 0;
} //main over //
/*OUTPUT*/
-9–
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 6
/* Date :- - -2023 */
/* OBJECTIVE: Write a program to find largest of FOUR given numbers. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to find largest of four given numbers. */
#include<stdio.h>
#include<conio.h>
void main()
{ float no, big;
int i;
fflush( stdin); clrscr();
printf("\n\t Please enter FOUR real numbers\t");
printf("\n\t Your number 1 is \t:\t");
scanf("%f", &no);
big = no;
for(i=2; i<=4; i++)
{
printf("\n\t Your number %d\t:\t", i);
scanf("%f", &no);
if(big<no)
big = no;
}
printf("\n\t The largest of the FOUR given numbers is %f", big);
getch(); return 0;
} //main over //
/*OUTPUT*/
Your number 2 : 9
Your number 3 : 2
Your number 4 : 7
Your number 2 : 5
Your number 3 : 7
Your number 4 : 9
- 10 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 7
Date :- - -2023 */
/* OBJECTIVE: Write program to find net salary when basic salary and other required
details are given. */
#include<stdio.h>
#include<conio.h>
void main()
{
float bs, gs, da, hra, it, pf, ns;
clrscr(); fflush(stdin);
if ( bs< 15000 )
{
hra = bs * 0.10;
da = bs * 0.90;
}
else
{
hra = 5000;
da = bs * 0.98;
}
gs = bs + hra + da;
printf ( "\n\t \Gross salary \t = Rs. %.0f", gs );
it = gs*(0.30);
pf = bs*(0.10);
ns = gs - it - pf;
getch(); return 0;
} // main over
- 11 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
Sign of Lecturer:-_______________
- 12 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 8
/* OBJECTIVE:-Write a program to solve the quadratic equation */
Date :- - -2023 */
void main( )
{double a, b, c, delta, x1, x2, x, real1, im1, real2, im2;
clrscr( );
fflush(stdin);
if(a==0)
{
printf("\n\n\t a=0?");
printf("\n\n\t -->This is not a quadratic equation!<--");
}
else
{ delta=b*b-4*a*c;
if (delta<0) printf( "\n\t NO REAL SOLUTION");
if(delta>0)
{ x1=(-b+sqrt(delta))/(2*a);
x2=(-b-sqrt(delta))/(2*a);
printf("\n\t Two distinct real roots");
printf("\t x1=%lf", x1);
printf("\t x2=%lf", x2);
}
else
{ if(delta==0)
{ x=-b/(2*a);
printf("\n\t Unique Real Solution is");
printf("\t x=%lf", x);
}
}
}
getch(); return 0;
}
- 13 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
- 14 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 9
/* Date :- - -2023 */
/* OBJECTIVE:- To write a C – program to obtain the REVERSED NUMBER. of a FIVE
digit numberentered through keyboard. */
//PROGRAM CODE: -
/* OBJECTIVE:-(a)A C - program to reverse the number. */
#include<stdio.h>
#include<conio.h>
void main()
{ long int sum, no, d1, d2, d3, d4, d5, number;
fflush(stdin);
clrscr();
printf("\n\t Please enter an integer with FIVE digits\t: ");
scanf("%ld", &number);
no=number;
d1=no%10;
no=no/10;
d2=no%10;
no=no/10;
d3=no%10;
no=no/10;
d4=no%10;
no=no/10;
d5=no%10;
sum=d1*10000+d2*1000+d3*100+d4*10+d5;
printf("\n\t Reversed number is %ld\n", sum);
getch(); return 0;
} //main over //
/*OUTPUT*/
Sign of Lecturer:-_______________
- 15 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 10
/* /*Date :- - -2023 */
/* OBJECTIVE:-Program to decide whether the number entered is Palindrome or not*/
#include<stdio.h>
#include<conio.h>
void main()
{ long int sum, i, m, no, d1, d2, d3, d4, d5, number;
fflush(stdin); clrscr();
printf("\n\t Please enter an integer with FIVE digits\t: ");
scanf("%ld", &number);
no=number;
d1=no%10;
no=no/10;
d2=no%10;
no=no/10;
d3=no%10;
no=no/10;
d4=no%10;
no=no/10;
d5=no%10;
sum=d1*10000+d2*1000+d3*100+d4*10+d5;
printf("\n\t Reversed number is %ld\n", sum);
if (number==sum)
{
printf("\n\t %ld is a Palindrome number\n", number);
}
else
{
printf("\n\t %ld is NOT a Palindrome number\n", number);
}
getch(); return 0;
} //main over //
/*OUTPUT*/
Sign of Lecturer:-_______________
- 16 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 11
/* Date :- - -2023 */
/* OBJECTIVE:- To write a C - program to calculate sum of digits of the
given number. */
//PROGRAM CODE: -
/* OBJECTIVE:-This program calculates sum of digits of the given number */
#include<stdio.h>
#include<conio.h>
void main()
{ int sum, i, rem, no, number;
clrscr();
fflush(stdin);
no=number;
sum=0;
for(i=1;i<=9;i++)
{
rem=no%10;
no=no/10;
sum=sum+rem;
if(no==0)break;
}
printf("\n\t Sum of digit=%d", sum);
getch(); return 0;
}// main over //
/*OUTPUT*/
Sum of digit=25
Sum of digit=24
Sum of digit=22
Sum of digit=10
Sign of Lecturer:-_______________
- 17 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 12
/* Date :- - -2023 */
/* OBJECTIVE:A program to find all the ARMSTRONG NUMBERS */
//PROGRAM CODE: -
/* OBJECTIVE:- (a)A program to find all the ARMSTRONG NUMBERS */
# include<stdio.h>
# include<conio.h>
void main( )
{
int sum, i, m, no, d1, d2, d3, d4, d5, number;
fflush(stdin);
clrscr();
/*OUTPUT*/
153
370
371
407
- 18 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 13
/* Date :- - -2023 */
/* OBJECTIVE: (a) A program to construct ARITHMETICprogression for given a and d
(b) A program to construct GEOMETRICprogression for given a and d */
/* OBJECTIVE:-(a) A program to construct ARITHMETICprogression for given a &d */
#include<stdio.h>
#include<conio.h>
void main()
{ int a, d, n, term, i;
clrscr(); fflush(stdin);
printf("\n\n\t Please enter first term and common difference and n of AP \t\n: ");
scanf("%d%d%d", &a, &d, &n);
printf("\n\t first term a=%d\n\t common difference d=%d", a, d);
printf("\n\t Arithmetic Progression up to %dth term\n", n);
term = a;
/*OUTPUT*/
Please enter first term and common difference and n of AP: 2 7 100
- 19 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/* OBJECTIVE:- (b) A program to construct GEOMETRICprogression for
given a and d */
#include<stdio.h>
#include<conio.h>
void main()
{ int a, r, n, i;
long term;
clrscr(); fflush(stdin);
printf("\n\n\t Please enter first term and common ratio and n of GP \t\n: ");
scanf("%d%d%d", &a, &r, &n);
printf("\n\tFirst term a\t=\t%d\n\tcommon ratio d\t=\t%d", a, r);
printf("\n\t Geometric Progression up to %dth term\n", n);
term = a;
for(i = 1; i <= n; i++ )
{
printf("\t %ld, ", term);
term = term*r;
}
getch(); return 0;
} // main over //
/*OUTPUT*/
First term a = 2
common ratio d = 3
Geometric Progression up to 15th term
Sign of Lecturer:-_______________
- 20 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 14
/*Date :- - -2023 */
/*OBJECTIVE: To write a C – program to find the value of nPr and nCr for given
n and r entered through keyboard. */
/* OBJECTIVE:- A program to find the value of nPr for given values of n and r*/
#include<stdio.h>
#include<conio.h>
void main()
{
double value;
int i, n, r;
clrscr();
fflush(stdin);
/*OUTPUT*/
N=7
R=2
nPr=7P2= 42
N=15
R=4
nPr=15P4= 32760
N=100
R=52
nPr=100P52= 7.517870952824667160000000000000000000000e+96
N=25
R=5
nPr=25P5= 6375600
Sign of Lecturer:-_______________
- 21 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OBJECTIVE: To write a C – program to find the value of nPr and nCr for given
n and r entered through keyboard. */
/* OBJECTIVE:- A program to find the value of nCr for given values of n and r*/
#include<stdio.h>
#include<conio.h>
void main()
{
double value, fact;
float i, n, r;
clrscr();fflush(stdin);
printf("\n\tnCr=%3.0fC%3.0f=%30.0lf", n, r, value);
getch(); return 0;
/*OUTPUT*/
Sign of Lecturer:-_______________
- 22 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 15
Date :- - -2023 */
/* OBJECTIVE: To write a C – programto find compound interest for given years.*/
#include<stdio.h>
#include<conio.h>
void main()
{
float a, i, j, p, p1, n, r;
fflush(stdin); clrscr();
printf("\n\t Please enter principle\t: \tRs. ");
scanf("%f", &p);
p1 = p;
for(j=1; j<=n; j++)
{
i = (p1*r)/100.0;
p1 = p1+i;
printf("\n\t j = %.0f\t Interest = Rs.%.2f\t p = Rs.%.2f", j, i, p1 );
}
getch(); return 0;
} //main over //
- 23 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
- 24 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 16
Date :- - -2023 */
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n, no, rem, even_count=0, odd_count=0, neg_count=0, pos_count=0, i =0;
clrscr(); fflush(stdin);
for(i=1;i<=n;i++)
{
printf("\tNumber=");
scanf("%d", &no);
rem=no%2;
(rem==0)?(even_count++):(odd_count++);
(no!=abs(no))?(neg_count++):(pos_count++);
}
getch(); return 0;
- 25 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
Number = -54
Number = 658
Number = 35941
Number = 3548
Number = 5
Number = -489
Number = -32
Number = 65
Number = -48
Number = -35
Sign of Lecturer:-_______________
- 26 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 17
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find factorial of a given number. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program to find factorial of a given number. */
#include<stdio.h>
#include<conio.h>
void main()
{ float i, no, fact;
fflush(stdin); clrscr();
printf("\n\t Please enter an integer\t: ");
scanf("%f", &no);
fact = 1;
for(i=1; i<=no; i++)
{
fact = fact*i;
}
getch(); return 0;
} //main over //
/*OUTPUT*/
Sign of Lecturer:-_______________
- 27 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :-18
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program using UDF with an argument and a return value.
A programme to determine whether a number entered through key-
board is a prime number or not. */
//PROGRAM CODE: -
/* OBJECTIVE:- Write a program using UDF with an argument and a return value. */
/* This programme will determine whether a number entered through key-board is a
prime number or not.*/
#include<stdio.h>
#include<conio.h>
int main()
{
int n, code;
fflush(stdin); clrscr();
printf("\n\t Enter a positive integer\t:\t");
scanf("%d", &n); // n is passed to the Prime() function
code = Prime(n); // The value returned from the
// function is assigned to code variable
if(code==1)
printf("\n\t %d is not a prime number\t\n", n);
else
printf("\n\t %d is a prime number\t\n", n);
getch(); return 0;
return 0;
}
int Prime(int n)
{
/* Integer value is returned from function Prime() */
int i;
return 0;
}
- 28 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
Sign of Lecturer:-_______________
- 29 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :-19
/* Date :- - -2023 */
/* Write a program that utilizes a UDF two find prime numbers between
two integers entered through key-board. */
/*This programme will demonstrate use of functions in C*/
# include <stdio.h>
# include <conio.h>
void main( )
{ long n1, n2, i;
double prime(long), p;
clrscr( ); fflush (stdin);
/*OUTPUT*/
- 30 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Sign of Lecturer:-_______________
- 31 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 20
/* Date :- - -2023 */
/* OBJECTIVE:-Write a program to solve the equation by N-R method. (Use of
preprocessor) */
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define EPSLON .0000001
#define n 100
#define f(x) 3*x-exp(x)
#define fd(x) 3-exp(x)
// #define f(x) x*x*x-3*x*x+7*x-8
// root=1.67411
// #define fd(x) 3*x*x-6*x+7
void main()
{int count;
float x0, xn, fx, fdx;
clrscr(); fflush(stdin);
if(fabs((xn-x0)/xn)<EPSLON||count > n)
{ break; }
else
{ x0=xn; }
count=count+1;
}
if(count>n)
{ printf("\n\t Divergent solution!\n"); }
else
{ printf("\n\t Root \t = \t %f", xn);}
getch(); return 0;
} // main over
- 32 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
Please enter x0 : 2
Root=1.512135
Please enter x0 : 3
Root=1.512135
Please enter x0 : 4
Root=1.512135
Please enter x0 : 5
Root=1.512135
Please enter x0 : 0
Root=0.619061
Please enter x0 : 10
Root=-0.000000
Please enter x0 : 25
Root=-NAN
Please enter x0 : 67
Divergent solution!
Sign of Lecturer:-_______________
- 33 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :-21
/* Date :- - -2023 */
/* OBJECTIVE:-Write a program to find value of the determinant of 2X2 and 3X3
matrices. */
clrscr(); fflush(stdin);
printf("\n\t Please enter the 2x2 matrix\t:\t" );
printf("\n***************Input****************\n");
printf("\n\t a=?\t:\t");
scanf("%f", &a);
printf("\n\t b=?\t:\t");
scanf("%f", &b);
printf("\n\t c=?\t:\t");
scanf("%f", &c);
printf("\n\t d=?\t:\t");
scanf("%f", &d);
printf("\n***************Output****************\n");
printf("\n*****************Matrix A*************\n");
- 34 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
a=? : 16
b=? : 9
c=? : 6
d=? : 4
***************Output****************
*****************Matrix A************
16.000000 9.000000
6.000000 4.000000
Sign of Lecturer:-_______________
- 35 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/* Date :- - -2023 */
#include <stdio.h>
#include <conio.h>
void main( )
{ int a[3][3], det, i, j;
clrscr( ); fflush(stdin);
printf("***************Input****************\n");
/*OUTPUT*/
- 36 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
A[0, 0] = 1
A[0, 1] = 5
A[0, 2] = 9
A[1, 0] = 7
A[1, 1] = 8
A[1, 2] = 6
A[2, 0] = 4
A[2, 1] = 3
A[2, 2] = 2
Diag(A)= 1 8 2
Sign of Lecturer:-_______________
- 37 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 22
/* Date :- - -2023 */
/* OBJECTIVE:- Write a program to find inverse of a 2X2 matrix.*/
clrscr(); fflush(stdin);
printf("\n\t Please enter the 2x2 matrix\t:\t" );
printf("\n***************Input****************\n");
printf("\n\ta=?\t:\t");
scanf("%f", &a);
printf("\n\t b=?\t:\t");
scanf("%f", &b);
printf("\n\t c=?\t:\t");
scanf("%f", &c);
printf("\n\t d=?\t:\t");
scanf("%f", &d);
printf("\n***************Output****************\n");
printf("\n*****************Matrix A*************\n");
- 38 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
a=? : 16
b=? : 9
c=? : 6
d=? : 4
***************Output******************
*****************Matrix A**************
16.000000 9.000000
6.000000 4.000000
Inverse of A =
0.400000 -0.900000
-0.600000 0.040000
Sign of Lecturer:-_______________
- 39 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :- 23
/* Date :- - -2023 */
printf("\n***************Output*****************\n");
printf("\n*****************Matrix A*************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", a[i][j] );
}
}
- 40 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
/*OUTPUT*/
***************Input****************
A[0, 0] = 1
A[0, 1] = 2
A[0, 2] = 3
A[1, 0] = 4
A[1, 1] = 5
A[1, 2] = 6
A[2, 0] = 7
A[2, 1] = 8
A[2, 2] = 9
***************Output****************
*****************Matrix A*************
Trace of A = 15.000000
Sign of Lecturer:-_______________
- 41 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
Practical no :-24
Date :- - -2023 */
/* OBJECTIVE:-Write a program to find the sum, deference, and multiplication of two
3X3 matrices entered through key-board.*/
printf("\n***************Matrix B****************\n");
- 42 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", b[i][j] );
}
}
printf("\n*****************Matrix A+B*************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", c[i][j] );
}
}
getch(); return 0;
***************Output****************
- 43 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
*****************Matrix A*************
***************Matrix B****************
- 44 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
#include<stdio.h>
#include<conio.h>
void main()
{ float sum, a[3][3], b[3][3], c[3][3];
int i, j, k;
clrscr(); fflush(stdin);
printf("\n\t Please enter the 3x3 matrix\t:\t" );
printf("\n***************Input****************\n");
for (i=0; i<=2; i++ )
{
for(j=0; j<=2; j++)
{
printf("\t A[%d, %d] = ", i, j );
scanf("%f", &a[i][j] );
}
}
for (i=0; i<=2; i++ )
{
for(j=0; j<=2; j++)
{
printf("\t B[%d, %d] = ", i, j );
scanf("%f", &b[i][j] );
}
}
printf("\n***************Output****************\n");
printf("\n*****************Matrix A*************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", a[i][j] );
}
}
printf("\n***************Matrix B****************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", b[i][j] );
}
}
- 45 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
printf("\n*****************Matrix A-B*************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", c[i][j] );
}
}
getch(); return 0;
****************Input****************
A[0, 0] = 87
A[0, 1] = 45
A[0, 2] = 32
A[1, 0] = 74
A[1, 1] = 98
A[1, 2] = 29
A[2, 0] = 61
A[2, 1] = 93
A[2, 2] = 92
B[0, 0] = 9
B[0, 1] = 3
B[0, 2] = 6
B[1, 0] = 2
B[1, 1] = 7
B[1, 2] = 8
B[2, 0] = 2
B[2, 1] = 9
B[2, 2] = 5
*****************Matrix A-B*************
- 46 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
int i, j, k; clrscr(); fflush(stdin);
printf("\n\t Please enter the 3x3 matrix\t:\t" );
printf("\n***************Input****************\n");
for (i=0; i<=2; i++ )
{
for(j=0; j<=2; j++)
{
printf("\t A[%d, %d] = ", i, j );
scanf("%f", &a[i][j] );
}
}
for (i=0; i<=2; i++ )
{
for(j=0; j<=2; j++)
{
printf("\t B[%d, %d] = ", i, j );
scanf("%f", &b[i][j] );
}
}
printf("\n***************Output****************\n");
printf("\n*****************Matrix A*B*************\n");
for(i=0; i<=2; i++)
{
printf("\n");
for (j=0; j <=2; j++ )
{
printf("%f\t", d[i][j] );
}
}
getch(); return 0;
}
/*OUTPUT*/
- 47 –
Core Practical: 5 Problem Solving using Programming, Dept of Mathematics, Virani Sc. College, Rajkot.
***************Input****************
A[0, 0] = 1
A[0, 1] = 2
A[0, 2] = 3
A[1, 0] = 4
A[1, 1] = 5
A[1, 2] = 6
A[2, 0] = 7
A[2, 1] = 8
A[2, 2] = 9
B[0, 0] = 9
B[0, 1] = 8
B[0, 2] = 7
B[1, 0] = 6
B[1, 1] = 5
B[1, 2] = 4
B[2, 0] = 3
B[2, 1] = 2
B[2, 2] = 1
***************Output****************
*****************Matrix A*************
***************Matrix B****************
*****************Matrix A*B*************
Sign of Lecturer:-_______________
- 48 –