3. If statements: The code in the file generates a random integer between 1 and 100. Write an if statement to determine

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

3. If statements: The code in the file generates a random integer between 1 and 100. Write an if statement to determine

Post by answerhappygod »

3 If Statements The Code In The File Generates A Random Integer Between 1 And 100 Write An If Statement To Determine 1
3 If Statements The Code In The File Generates A Random Integer Between 1 And 100 Write An If Statement To Determine 1 (53.66 KiB) Viewed 52 times
3 If Statements The Code In The File Generates A Random Integer Between 1 And 100 Write An If Statement To Determine 2
3 If Statements The Code In The File Generates A Random Integer Between 1 And 100 Write An If Statement To Determine 2 (44.8 KiB) Viewed 52 times
3. If statements: The code in the file generates a random integer between 1 and 100. Write an if statement to determine if this number is even. If it is even use disp to say so ("The number 4 is even."), and if not, say that the number is odd. Hint: The function mod is the key to writing this if statement. Having remainder 0 when divided by 2 means that a number is even. 4. For loops: The Fibonacci numbers are a common concept in mathematics, and they are easily generated using a for loop. Write a loop to generate the first 20 Fibonacci numbers and store them all in an array. After you are done, display the array. The Fibonacci numbers F, are defined by F₁1 MATLAB ASSIGNMENT F₂ = 1 Fn = Fn-1 + Fn-2 so that at each step, you need to add up the previous two numbers to get the next one. This recursion lends itself very well to a for loop. f(x)=sin(x) and g(x)= x-1 over the range [0, 3]. Draw f(x) in To

% Generates a random number between 1 and 100 randNum E randi (100, 1) if randNum = G disp(['The number is' num2str(randNum) 'odd']); disp([ 'The number is' num2str(randNum) 'even']); else end % Write the if statements here
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply