Skip to content
VUBuddy

MTH643 Practice Questions Solved Set 2 by Mahar Afaq Safdar Muhammadi

Introduction to MATLAB PDF 1.1 MBUpdated 23 Oct 2026
Quiz MTH643 Practice Questions Solved Set 2 by Mahar Afaq Safdar Muhammadi PDF 1.1 MB
vubuddy.com
Type
Quiz
Course
MTH643 Introduction to MATLAB
Size
PDF 1.1 MB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 1.1 MB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 5, 6, 7 of 16. Download the file for all 16 pages.

Output:

Lecture # 10

Question: Write a for loop to add first 20 numbers which are divisible by 5.

Solution:

%Write a for loop to add first 20 numbers which are divisible by 5. v=1:100; sum=0; for i=5:5:length(v) sum=sum+v(i); end disp(sum)

Question: Write a program which takes a number as an input from the user and then using the for loop display all of its divisors.

Solution:

%Write a program which takes a number as an input from the user and then %using the for loop display all of its divisors.

n=x; for k=1:n if mod(x,k)==0 disp(k) end end Question: Write a program which compute the factorial of any number.

Solution:

%Calculate the factorial of any number. number=input(' Enter a number:'); fact=1; if number<0 fprintf(' The number you have entered is negative'); else for i=1:number fact=fact*i; end disp(fact); end

Question: Write a program in MATLAB that compute the following sum.

Solution:

%Write a program in MATLAB that compute the following sum. %[summation i=1:10 (3x^i)]. syms x sum=0; for i=1:10 sum=sum+3*x^i; end disp(sum)

Solution:

%Write a program in MATLAB that compute the following sum. %[summation j=1:6 summation i=1:5 (3^(i+j)]. sum=0; for j=1:6 for i=1:5 sum=sum+3^(i+j); end end disp(sum) Question: Write a program which prints all the numbers divisible by 3 and 5 for a given number.

Solution:

%Write a program which prints all the numbers divisible by 3 and 5 for a given number.

n=x; for (k=1:n) if mod(k,3)==0 && mod(k,5)==0 disp(k) end end

Lecture # 11

Question: Write a function with name 'myfunction' which takes any two numbers as an input and returns the greater number.

All MTH643 files →
MTH643 Introduction to MATLAB All MTH643 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.