Using while loop and nested if statement develop a program to satisfy the following condition

Using while loop and nested if statement develop a program to satisfy the
following condition once user data is prompted to be entered:
a. An even unsigned integer or odd unsigned integer
b. A Negative number

댓글 수: 2

There are no unsigned integers that are also negative, so there is no solution to this question.

댓글을 달려면 로그인하십시오.

 채택된 답변

This is your home work...you have to do it on your known. REad about mod to know whether number is even or odd.
if mod(n,2)==0
fprintf("%d is even number\n",n)
elseif
fprintf("%d is odd number\n",n)
end
To know the sign you can use the function sign.
if n < 0
fprintf("%d is negative number\n",n)
end
To declare numbers as integers read about int16, int32, unit16 etc.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2021년 6월 21일

댓글:

2021년 6월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by