2.
clc;
clear;
a=0;
for i=1:1000;
x=i^2;
x
a=a+x;
end;
Output
3.
clc;
clear;
a=0;
a=input('enter the number:');
if a<0;
y=sqrt(a^5+1);
elseif a<=10 || a>=0;
y=3^a+1;
elseif a>=10;
y=9*sin(5^a-50)+31;
else
print('Entered value cant be operated');
end
a
y
Output
A=-5
a=5
a=15
4.
clc;
clear;
a=0;
a=input('enter the number:');
disp('value at');
a
if a<-1;
y=exp(a)+1;
elseif a>=-1 && a<=5;
y=2+cos(pi*a);
elseif a>=5;
y=10*(a-5)+1;
else
print('Entered value cant be operated');
end
y
Output
A=-5
5.
clc;
clear;
a=0;
for k=1:10;
k
x=5*k*3;
y=a+x;
a=x+y;
end
a
output
A=3
A=15
6.
clc;
clear;
x=0;
a=0;
while x<1e+4;
a=a+1;
x=5*a^2-2*a+x;
end
disp('terms')
disp(a)
disp('sum')
disp(x)
output
7.
clc;
clear;
x=0;
a=0;
while x<2000;
a=a+1;
x=3*a^2+a;
end
disp('terms')
disp(a/2)
disp('sum')
disp(x)
output
Solved lab#5