You are on page 1of 2

QUESTAO 1

function z=soma(x,y)
z=x+y;
return
clear all; clc;
x=input('digite valor: ');
y=input('digite valor: ');
z=soma(x,y);
fprintf('X+Y= %i\n', z);

QUESTAO 2

function z=multi(x,y)
z=x*y;
return
clear all; clc;
x=input('digite valor: ');
y=input('digite valor: ');
z=multi(x,y);
fprintf('X*Y= %i\n', z);

QUESTAO 3

function z=fatorial(x)
z=1;
for i=1:x
z=i*z;
end
return
clear all; clc;
while(x~=-1)
x=input('digite valor: ');
z=fatorial(x);
fprintf('fat de x = %i\n', z);
end;

QUESTAO 4

function vet=preenche(x)
for i=1:x
vet(i)=0;
end
return
function imp_vetor(vet)
tam=length(vet);
for i=1:tam
fprintf('vetor(%d) = %d\n',i,vet(i));
end
return
clear all; clc;
x=input('digite valor: ');
vet=preenche(x);
imp_vetor(vet);

QUESTAO 5 (usa funçao de questoes anteriores)

function vetor=soma_vet(v,num)
tam=length(v);
for i=1:tam
vetor(i)=v(i)+num;
end;
return
clear all; clc;
x=input('digite valor: ');
v=preenche(x);
imp_vetor(v);
num=input('\ndigite valor: ');
v=soma_vet(v,num);
imp_vetor(v);

QUESTAO 6(terminar)

function v=vet(x)
for i=1:x
v(i)=input(' ');
end
return
function M=maior_valor(v,x)
tam=length(x);
for i=1:tam
if(v(1)<v(i))
v(1)=v(i);
end;
end;
return
clear all; clc;
x=input('digite valor: ');
v= vet(x);
M=maior_valor(v,x);

You might also like