필터 지우기
필터 지우기

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일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by