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 C program that finds the odd, composite numbers between 10 and 500 in xterm...

    Write a C program that finds the odd, composite numbers between 10 and 500 in xterm a. Composite means it is not prime, i.e., “C” is composite if there exists an A and B such that A>1, B>1, and A*B = C. b. Odd means that it is not divisible by 2. c. Therefore “odd, composite”, means both odd and composite'' Output should be: 15 is a composite number. 21 is a composite number. 25 is a composite number. 27...

  • 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 program in C that asks for an integer n, if n is greater than...

    Write a program in C that asks for an integer n, if n is greater than 100 or if it is less than 1, output an error message. If n is in the range {1, . . . , 100} then if n is either 2,3,5, or 7, output “YES”; or if n is not divisible into 2,3,5 or 7 also output “YES” if n 6= 1; otherwise, output “NO”. Yes, you’re right, a very simple program that checks if...

  • 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.

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