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.
priya ranjan
priya ranjan 2021 年 6 月 21 日
Thank you

サインインしてコメントする。

 採用された回答

KSSV
KSSV 2021 年 6 月 21 日
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.

2 件のコメント

priya ranjan
priya ranjan 2021 年 6 月 21 日
Actually I am beginner for matlab
KSSV
KSSV 2021 年 6 月 21 日
Not an issue...you have good documentation for MATLAB.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops 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