Professional Documents
Culture Documents
Write program for the following problems (Assume right units. Search and
use library functions wherever possible). Unless specified, built-in functions
may be used if necessary.
1. Display your country name.
2. Compute the area and circumference of a circle given the radius.
3. Compute simple interest given the interest rate, principal and
duration.
4. Compute compound interest given the interest rate, principal,
compounding-nature and duration.
5. Swap contents of two variables without using intermediate variables.
6. Factorial of a single digit number.
7. Absolute value of a number.
8. Largest of three numbers.
9. Logarithm of a number.
10.Y=sin(1+ 2)+cos(1- 2) given 1 and 2 in degrees.
11.Average of the numbers in 3x4 matrix.
Prepared By
Page
Prepared By
Page
Prepared By
Page
3. Compute simple interest given the interest rate, principal and duration.
clc;
clear all;
close all;
p=input('principle amount p=');
r=input('rate of intrest b=');
t=input('time taken to return amount t=')
disp('principle amount p');
disp(p);
disp('rate of intrest r');
disp(r);
disp('time taken to return amount t');
disp(t);
I=p*r*t;
disp('intrest');
disp(I);
Prepared By
Page
Compute compound interest given the interest rate, principal, compoundingnature and duration.
clc;
close all;
clear all;
p=7500;
r=0.06;
n=12;
t=5;
A=p*(1+(r/n))^(n*t);
disp(A);
Prepared By
Page
Prepared By
Page
clc;
close all;
clear all;
f=factorial(22);
disp('f=');
disp(f);
Prepared By
Page
Prepared By
Page
Prepared By
Page
clc;
clear all;
close all;
a=input('matrix a=');
disp('matrix a')
disp(a);
b=input('matrix b=');
disp('matrix b')
disp(b);
s=a+b;
disp('addition of matrix=');
disp(s);
Prepared By
Page
Prepared By
Page
clc;
clear all;
close all;
a=input('matrix a=');
disp('matrix a')
disp(a);
b=input('matrix b=');
disp('matrix b')
disp(b);
p=a*b;
disp('multiplication of matrix=');
disp(p);
Prepared By
Page
clc;
clear all;
close all;
disp('enter the value of coefficient ');
a=input ('a= ');
b=input('b= ');
c=input ('c= ');
X1=(-1*b+sqrt (b*b-4*a*c))/(2*a);
X2=(-1*b+sqrt (b*b-4*a*c))/(2*a);
disp ('roots are');
disp (X1);
disp(X2);
Prepared By
Page
Compute mean, median, standard deviation and variance of a set of data using formulae
and verify using built-in functions.
Calculation of mean,
clc;
clear all;
close all;
A=[6,11,7];
M=mean(A);
disp('mean=');
disp(M);
Calculation of median
clc;
clear all;
close all;
A=[1:11];
M=median(A);
disp('median=');
disp(M);
Prepared By
Page
clc;
clear all;
close all;
A=[9, 2, 5, 4, 12, 7, 8, 11 ];
s=std(A);
disp('s=');
disp(s);
1. Absolute
value of
number.
clc;
close all;
clear all;
a=[-3+4i];
y=abs(a);
Prepared By
Page
disp(y);
Page
M=mean(a);
disp(M);
Logarithm of a number.
clc;
close all;
clear all;
x=8;
disp('x=');
disp(x);
y=log(x);
disp('logarithm');
disp(y);
Prepared By
Page
Prepared By
Page
Prepared By
Page