rand but even numbers

8 ビュー (過去 30 日間)
stephen aboasu
stephen aboasu 2015 年 9 月 12 日
回答済み: Star Strider 2015 年 9 月 12 日
how do I write a script that will generate one random integer between 1 and 100, and will print whether the random integer is an even or an odd number.

回答 (1 件)

Star Strider
Star Strider 2015 年 9 月 12 日
Two functions, randi and rem or mod are all you need. Of course you’ll also need one of the print functions such as fprintf or sprintf, but that’s obvious.

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by