0% found this document useful (0 votes)
45 views2 pages

'Enter An Alphabet ASCII Code:': X Input (

The document provides MATLAB code solutions to two problems: 1) A code that determines if an input character is a vowel or consonant based on its ASCII code. 2) A function that determines if a given year is a leap year or not, by checking if the year is divisible by 400, or divisible by 4 but not 100. The function returns a true/false status.

Uploaded by

Jaan Jaan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

'Enter An Alphabet ASCII Code:': X Input (

The document provides MATLAB code solutions to two problems: 1) A code that determines if an input character is a vowel or consonant based on its ASCII code. 2) A function that determines if a given year is a leap year or not, by checking if the year is divisible by 400, or divisible by 4 but not 100. The function returns a true/false status.

Uploaded by

Jaan Jaan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

6.

Write a MATLAB code that determines whether a letter is VOWEL or a


CONSONANT.
Solution:

x=input('enter an alphabet ASCII code:');


if x==97||x==101||x==105||x==111||x==117||x==65||x==69||x==73||x==79||x==85
disp('it is vowel');
else
disp('it is consonant');
end
result;
enter an alphabet ASCII code:117
it is vowel
enter an alphabet ASCII code:66
it is consonant
>>

7. Write a MATLAB code that determines whether a year is Leap or not. (Avoid using
the built in [2] function leapyear).
Solution:

function [ status ] = leapyear( year )


if mod(year, 400) == 0
status = true;
elseif mod(year, 4) == 0 && mod(year, 100) ~= 0
status = true;
else
status = false;
end
end
%(for true is 1 and for false is 0)

[ status ] = leapyear( 2000 )


status =
1
>> [ status ] = leapyear( 2001 )
status =
0
>> [ status ] = leapyear( 2016 )
status =
1

You might also like