Created
December 28, 2024 11:31
-
-
Save otuva/d886efb6d7e21132dfe4e4a23574586a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% isim | |
% num | |
% Computer Engineering | |
% CEN103 Introduction to Programming | |
% Project 2 | |
% 20-21 Autumn | |
% Deniz Dal | |
% while loops cuz we're waiting for user to type -1 | |
number = input("number = ") | |
questiond = number | |
questione = number | |
questionf = number | |
questiona = 0 | |
questiona_counter = 0 | |
questionb = 0 | |
questionb_counter = 0 | |
questionc = 1 | |
questionc_counter = 0 | |
while number ~= -1 | |
number = input("number = ") | |
% if integer | |
if number == round(number) | |
% if biggest | |
if number > questionf | |
questionf = number | |
end | |
% neg odd integer | |
if number < 0 && mod(number,2) == 1 | |
if number > questiond | |
questiond = number | |
end | |
% if integer and negative and odd then take the arithmetic mean | |
questionb = questionb + 1/number | |
questionb_counter = questionb_counter + 1 | |
% positive even int | |
elseif number > 0 && mod(number,2) == 0 | |
% if integer and positive and even then take the geometric mean | |
questionc = questionc * number | |
questionc_counter = questionc_counter + 1 | |
end | |
% if float | |
else | |
% if biggest number | |
if number > questionf | |
questionf = number | |
end | |
% smallest float | |
if number < questione | |
questione = number | |
end | |
if number > 0 | |
% if float and positive then take the arithmetic mean | |
questiona = questiona + number | |
questiona_counter = questiona_counter + 1 | |
end | |
end | |
end | |
fprintf("a = %g\n", questiona/questiona_counter) | |
fprintf("b = %g\n", questionb_counter/questionb) | |
fprintf("c = %g\n", (questionc)^(1/questionc_counter)) | |
fprintf("d = %d\n", questiond) | |
fprintf("e = %g\n", questione) | |
fprintf("f = %d\n", questionf==round(questionf)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment