In matlab program 1Q: (Use for loop and no vectors (arrays)). Write a program to
ID: 3631324 • Letter: I
Question
In matlab program1Q:
(Use for loop and no vectors (arrays)).
Write a program to find the following sums using for loops.
a) + + ….
b) + + + …. (use 500 terms)
2Q:
(Use while loop and no vectors (arrays)).
Write a program to performing the following:
• Enter a positive integer n from the keyboard. Assume n is always an even number
• Enter n positive integers from the keyboard.
• Find the maximum of the first half of integers and the minimum of the last half of integers.
• Find the sum of all even numbers and the average of all odd numbers
• All output should be directed to the screen monitor.
Sample input
10
23 12 45 13 67 18 14 98 89 35
Sample output
The maximum of the first half is: 67
The minimum of the second half is: 14
The sum of all even numbers is: 142
The average of all odd numbers is: 45.33
Grading:
Ex#1 Ex#2 EX#3
User prompts 0. 25 0.25 0. 25
Comments 0. 25 0.25 0. 25
Identifier names 0. 25 0.25 0. 25
Indentation 0. 25 0.25 0. 25
Program code 2 4 4.5
Output correctness 1.5 1.5 1.75
Output format 0.5 0.5 0.75
Total 5 7 8
Explanation / Answer
The first question is already answered in your other thread. 2Q) clear;clc n = input('Enter a positive even number: '); x = input('Enter n positive integers from the keyboard: '); %% determining the max value of first half my_max = 0; i = 1; while i my_max my_max = x(i); end i = i+1; end fprintf('The maximum of the first half is: %d ',my_max); %% detemining the min value of second half my_min = x(n); i = n/2+1; while iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.