Count Even And Odd Numbers In Matlab

[Solved] Count Even And Odd Numbers In Matlab | Matlab - Code Explorer | yomemimo.com
Question : count even and odd numbers in matlab

Answered by : rasel-ahmed-9kilyai1mdfd

clc; clear all ;
a = input("Please enter 1st number: ");
nE = 0 ; nO = 0 ;
if mod(a,2)==0 disp("The 1st number is EVEN"); nE = nE+1 ;
else disp("The 1st number is ODD"); nO = nO+1 ;
end
b = input("Please enter 2nd number: ");
if mod(b,2)==0 disp("The 2nd number is EVEN"); nE = nE+1 ;
else disp("The 2nd number is ODD"); nO = nO+1 ;
end
c = input("Please enter 3rd number: ");
if mod(c,2)==0 disp("The 3rd number is EVEN"); nE = nE+1 ;
else disp("The 3rd number is ODD"); nO = nO+1 ;
end
d = input("Please enter 4th number: ");
if mod(d,2)==0 disp("The 4th number is EVEN"); nE = nE+1 ;
else disp("The 4th number is ODD"); nO = nO+1 ;
end
e = input("Please enter 5th number: ");
if mod(e,2)==0 disp("The 5th number is EVEN"); nE = nE+1 ;
else disp("The 5th number is ODD"); nO = nO+1 ;
end
fprintf('there are %d number of Even Numbers\n',nE)
fprintf('there are %d number of Odd Numbers\n',nO)

Source : | Last Update : Mon, 27 Jun 22

Answers related to count even and odd numbers in matlab

Code Explorer Popular Question For Matlab