In MATLAB language Write a function, called digits_funct that is able to calculate the number of digits and the summatio
Posted: Mon May 02, 2022 12:08 pm
In MATLAB language
Write a function, called digits_funct that is able to calculate
the number of digits and the summation of the digits. The input of
this function is N (entered number) and the outputs are
number_digits and sum_digits.
Write a function, called print_average_funct that is able to
calculate the average of 3 numbers and print it. The inputs of this
function are a, b and c. No output is required.
Write a function, called prime_funct that receives one parameter
n, and checks whether the number is prime or not. The input of this
function is n and the output is result_prime.
Now after you created the three functions, you have to write a
program that can call the above functions according to the user’s
choice. Write a menu driven that allows the user to select from the
following options:
To use the digits function you have to enter A.
To use the average function you have to enter B.
To use the prime function you have to enter C.
To Exit the program you have to enter D.
Once the user select one of the above choices you have to read
the value entered by the user and then to call the respective
function. If the user entered a number that is not A or B or C or
D, the program should ask the user to re-enter again.
Then, you have to use “input” to enter the values of the
variables (inputs of the functions).
For the digits function, you have to enter only positive number.
For the average function, you have to enter greater than or equal
to zero values and for the prime function you have to enter greater
than 1 values.
For all of the functions, the program should ask the user to
re-enter again if the user entered wrong numbers.
Write a function, called digits_funct that is able to calculate
the number of digits and the summation of the digits. The input of
this function is N (entered number) and the outputs are
number_digits and sum_digits.
Write a function, called print_average_funct that is able to
calculate the average of 3 numbers and print it. The inputs of this
function are a, b and c. No output is required.
Write a function, called prime_funct that receives one parameter
n, and checks whether the number is prime or not. The input of this
function is n and the output is result_prime.
Now after you created the three functions, you have to write a
program that can call the above functions according to the user’s
choice. Write a menu driven that allows the user to select from the
following options:
To use the digits function you have to enter A.
To use the average function you have to enter B.
To use the prime function you have to enter C.
To Exit the program you have to enter D.
Once the user select one of the above choices you have to read
the value entered by the user and then to call the respective
function. If the user entered a number that is not A or B or C or
D, the program should ask the user to re-enter again.
Then, you have to use “input” to enter the values of the
variables (inputs of the functions).
For the digits function, you have to enter only positive number.
For the average function, you have to enter greater than or equal
to zero values and for the prime function you have to enter greater
than 1 values.
For all of the functions, the program should ask the user to
re-enter again if the user entered wrong numbers.