Effacer les filtres
Effacer les filtres

Script that returns the square of a prompted number

2 vues (au cours des 30 derniers jours)
Itzel
Itzel le 4 Oct 2023
Commenté : James Tursa le 4 Oct 2023
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 commentaire
James Tursa
James Tursa le 4 Oct 2023
If x is a scalar variable, x^2 is the square of that variable.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Oct 2023
Déplacé(e) : Adam Danz le 4 Oct 2023
  1 commentaire
Itzel
Itzel le 4 Oct 2023
Déplacé(e) : Adam Danz le 4 Oct 2023
Thank you walter!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by