Assignment 3.1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Lesson 2: Essential Mathematics Part 2

Assignments

20.01.2024
Manikanta Naupada
nmanikanta539@gmail.com

www.flowthermolab.com| Student Assignment


Assignment 3.1
Numbers = input ("input array of 10 numbers:");
len = length(Numbers);
disp('Unsorted array of 10 numbers');
disp(Numbers);
for i = 1:len
for j = i+1:len
if Numbers(i) > Numbers(j)
temp = Numbers(i);
Numbers(i) = Numbers(j);
Numbers(j) = temp;
end
end
end
disp('Sorted array of 10 numbers');
disp(Numbers);

www.flowthermolab.com| Student Assignment


Assignment 3.1

Age = input("Enter Person Age:")


if Age > 60
fprintf("The person is a senior citizen\n");
elseif 21 < Age && Age <= 60
fprintf("The person is working\n");
elseif 17 < Age && Age <= 21
fprintf("The person is a college student\n");
elseif 6 < Age && Age <= 17
fprintf("The person is in the school\n");
elseif 0 < Age && Age <= 6
fprintf("The person is at home\n");
elseif Age == 0
fprintf("The person is just born\n");
else
fprintf("invalid entry\n");
end

www.flowthermolab.com| Student Assignment


Assignment 3.1

disp('Enter a 3x3 matrix');


myMatrix = input('');
if size(myMatrix) == [3, 3]
det_value = det(myMatrix);
disp('The 3x3 matrix is:');
disp(myMatrix);
disp(['The determinant of the matrix is: ' num2str(det_value)]);
else
disp('Error: Please enter a valid 3x3 matrix.');
end

www.flowthermolab.com| Student Assignment


Assignment 3.2

www.flowthermolab.com| Student Assignment

You might also like