Search
 
SCRIPT & CODE EXAMPLE
 

MATLAB

count even and odd numbers in matlab

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
',nE)
fprintf('there are %d number of Odd Numbers
',nO)
Comment

PREVIOUS NEXT
Code Example
Matlab :: pyspark dense 
Matlab :: matlab make symbolic matrix 
Matlab :: matlab plotting multiple lines on one graph 
Matlab :: octave wait 
Matlab :: matlab variables 
Matlab :: matlab what comes instead of drawmode 
Matlab :: octave return dimensions 
Basic :: vb string to int32 
Basic :: freecodecamp basic algorithm scripting return largest numbers in arrays 
Basic :: Detailview with form mixing 
Basic :: como colocar aspas duplas em vbnet 
Elixir :: elixir length of list 
Elixir :: phoenix system get env 
Elixir :: elixir format code 
Elixir :: elixir nested if 
Scala :: scala map example 
Scala :: how loop in scala 
Actionscript :: cannot connect to rabbitmq localhost inside docker container 
Excel :: google sheets return multiple columns with vlookup 
Excel :: google sheets filter cells that match word 
Perl :: Perl (perl 5.28.1) sample 
Pascal :: pascal sleep 
Powershell :: How to display firewall rule ports with powershell 
Gdscript :: godot saving enum names in variable 
Erlang :: tcp client erlang 
Assembly :: Generate random strings only with uppercase letters and digits in Python 
Assembly :: how to check whether a row contains a numeric value or not in df 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery add input placeholder 
Javascript :: p5.js cdn 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =