Question

Write a program in a script file that finds the smallest odd integer that is also...

Write a program in a script file that finds the smallest odd integer that is also divisible by 3 and whose cube is greater than 4000. Use a loop in the program. The loop should start from 1 and stop when the number is found. The program should print the message: The required number is: [and then prints the number]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have attached the MATLAB code and its output. Feel free to ask any doubt/query/confusion.

MATLAB CODE :

close all;
clear all;
clc;
number = 1;
i=0;
while i == 0
if number^3 > 4000
if rem(number,3)==0
if rem(number,2)==1
break
end
end
end
number = number+1;
end
fprintf('The required number is : %i',number)

OUTPUT :

Screenshot of MATLAB code and its Output :

Add a comment
Know the answer?
Add Answer to:
Write a program in a script file that finds the smallest odd integer that is also...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • Create a new MATLAB Script file named MT3P3_itname.m. In your script file perform the following calculations:...

    Create a new MATLAB Script file named MT3P3_itname.m. In your script file perform the following calculations: Prompt the user to enter an integer. Use a multiple if-elseif structure to determine the following: Confirm that the number is an integer. If not, the program displays message 1. Check if the number is divisible by 2 and displays message 2. Check if the number is divisible by 3 and displays message 3. For anything other than 1, 2, or 3, the program...

  • Write a program that reads an integer k from user and finds the number of elements...

    Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assignment4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below. Assume the...

  • Exercise 9.2 Write a Python program that collects from the user a single integer. Have the...

    Exercise 9.2 Write a Python program that collects from the user a single integer. Have the program print “EVEN” if the integer is divisible by 2, and “ODD” if the integer is not divisible by two. [Use the % operator to compute the two’s modulus (remainder of division by two)] Exercise 9.3 Write a Python program that collects from the user two integers. Have the program print “Yes” if the two integers are BOTH greater than 10. Do nothing if...

  • Write a program asking the user for an integer then find the lowest factor that is...

    Write a program asking the user for an integer then find the lowest factor that is not a 2, 3, or 5. Hint: Use while or do-while with a flag. Think this way - you have found the answer when you find the lowest factor that is not divisible by 2, 3, or 5 (hint: %) but the number % factor = zero. Start factor at 2 then increment until the answer is found, then change the flag to stop...

  • Write a program asking the user for an integer then find the lowest factor that is...

    Write a program asking the user for an integer then find the lowest factor that is not a 2, 3, or 5. Hint: Use while or do-while with a flag. Think this way - you have found the answer when you find the lowest factor that is not divisible by 2, 3, or 5 (hint: %) but the number % factor = zero. Start factor at 2 then increment until the answer is found, then change the flag to stop...

  • Write a program that finds either the largest or smallest of the ten numbers as command-line...

    Write a program that finds either the largest or smallest of the ten numbers as command-line arguments. With –l for largest and –s for smallest number, if the user enters an invalid option, the program should display an error message. Example runs of the program: ./find_largest_smallest –l 5 2 92 424 53 42 8 12 23 41 output: The largest number is 424    ./find_largest_smallest –s 5 2 92 424 53 42 8 12 23 41 output: The smallest number is...

  • Write a java program making use of methods that finds the smallest of any three numbers...

    Write a java program making use of methods that finds the smallest of any three numbers that the user inputs. You must use JoptionPane to input the three numbers. A first method must be called and used to develop logic to find the smallest of the three numbers. A second method must be used to print out that smallest number found.

  • WHILE LOOPS (13 points) Write a MATLAB program to find the smallest integer N such that:...

    WHILE LOOPS (13 points) Write a MATLAB program to find the smallest integer N such that: i> limit For example, if the limit is 5, the smallest N would be 3 since 1 + 2 + 3 = 6, and 6 > 5. If the limit is 15, the smallest N is 6 because 1+ 2+ 3+ 4+ 5+ 6 = 21. Note that N is not 5 in this case because 1+ 2+ 3+ 4+ 5 = 15, and...

  • In Python Exercise – For & While Loops Create a new file called loops.py and use...

    In Python Exercise – For & While Loops Create a new file called loops.py and use it for all parts of this exercise. Remember the difference between input and raw input? Be sure to test your code for each part before moving on to the next part. Write a program using a for loop that calculates exponentials. Your program should ask the user for a base base and an exponent exp, and calculate baseexp. Write a program using a while...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT