フィルターのクリア

Script that returns the square of a prompted number

2 ビュー (過去 30 日間)
Itzel
Itzel 2023 年 10 月 4 日
コメント済み: James Tursa 2023 年 10 月 4 日
Write a script that will prompt the user for a number, and will print the square of the user’s number in the following format:
Enter a number: 11.1
Your number squared is 123.21
I know how to write the part of the script that prompts the user for a number, but I was wondering how to get it to print the square of whatever number the user gives. I am not looking for the entire code, I would just like an explanation on how to get it to print the square of the number one gives.
  1 件のコメント
James Tursa
James Tursa 2023 年 10 月 4 日
If x is a scalar variable, x^2 is the square of that variable.

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 10 月 4 日
移動済み: Adam Danz 2023 年 10 月 4 日
  1 件のコメント
Itzel
Itzel 2023 年 10 月 4 日
移動済み: Adam Danz 2023 年 10 月 4 日
Thank you walter!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by