You are on page 1of 2

SEGUNDA PRACTICA DE METODOS NUMERICOS

a.Diga si un numero es par o impar


n=input('ingrese el numero: ');
if mod(n,2)==0;
fprintf('el nuemro %f es par\n',n);
else
fprintf('el numero %f es impar\n',n);
end

b.producto o suma
a=input('ingrese primer numero: ');
b=input('ingrese segundo numero: ');
if (a>0&b>0)
fprintf('el producto es %f \n',a*b)
else
fprintf('la suma es %f \n',a+b)
end

c. De 5 numeros el menor es:


x=[0 0 0 0 0];
x(1)=input('ingrese 1ºnumero: ');
x(2)=input('ingrese 2ºnumero: ');
x(3)=input('ingrese 3ºnumero: ');
x(4)=input('ingrese 4ºnumero: ');
x(5)=input('ingrese 5ºnumero: ');
sort(x)
fprinf('el nuemro menor es %f\n',x(1))

d. algoritmo de las raices de una ecuación cuadrática


a=input('ingrese a: ');
b=input('ingrese b: ');
c=input('ingrese c: ');
if a>0
R1=(-b+sqrt(b^2-4*a*c))/(2*a)
R2=(-b-sqrt(b^2-4*a*c))/(2*a)
end

e.¿se puede formar un triangulo?


x=[0 0 0];
x(1)=input('ingrese 1ºlongitud: ');
x(2)=input('ingrese 2ºlongitud: ');
x(3)=input('ingrese 3ºlongitud: ');
sort(x)
if (x(3)-x(1))<x(2)& x(2)<(x(3)+x(1))
disp('SE PUEDE FORMAR UN TRIANGULO')
if (x(3))^2==(x(1))^2+(x(2))^2
disp('EL TRIANGULO ES RECTANGULO')
elseif (x(3))^2>(x(1))^2+(x(2))^2
disp('EL TRIANGULO ES OBTUSANGULO')
elseif (x(3))^2<(x(1))^2+(x(2))^2
disp('EL TRIANGUILO ES ACUTANGULO')
end
else disp('NO SE PUEDE FORMAR UN TRIANGULO')
end
f.Algoritmo que grafique y evalue la función.
function y=f(x)
global fun
if x<=0
y=x.^2+1;
elseif 0<x & x<3
y=x.^2+3*x+2;
elseif x>=3
y=x+1;
end

g.Lea 2 enteros y obtenga el valor nuerico.


a=input('ingrese a: ')
b=input('ingrese b: ')
if a^2-b^2<0
disp('f(x)'); 2*a+b
elseif a^2-b^2==0
disp('f(x)'); a^2-2*b
else
disp('f(x)'); a+b
end

h.Lea 3 nuemros e indique el intermedio.


x=[0 0 0]
x(1)=input('ingrese 1ºnumero: ');
x(2)=input('ingrese 2ºnumero: ');
x(3)=input('ingrese 3ºnumero: ');
sort(x)
fprinf('el nuemro intermedio es %f\n',x(1))

i.Dada la hora y minutos y segundos encduentre la hora del segundo


anterior.
j.En una universidad tiene como política considerar 3 notas en cada
curso la nota de trabajos T,la nota de medio ciclo M y la nota de fin de
ciclo cada una con un peso de 20% ,40%,40% respectivamente,un
alunmo e scalificado según lo siguiente:
bueno: su promedio esta entre 16 y 20
regular: su promedio esta entre 11 y 15
malo: su promedio esta entre 6 y 10
a=input('ingrese nota de trabajos: ');
b=input('ingrese nota de medio ciclo: ');
c=input('ingrese nota de fin de ciclo: ');
p=(20*a+40*b+40*c)/100
if p>16 & p<20
disp('el alumno es BUENO')
elseif p>11 & p<15
disp('el alunmo es REGULAR')
elseif p>6 & p<10
disp('el alumno es MALO')
end

You might also like