MTH643 Practice Questions Solved by Mahar Afaq Safdar Muhammadi
- Type
- Quiz
- Course
- MTH643 Introduction to MATLAB
- Size
- PDF 1 MB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
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.
Related MTH643 files
All MTH643 files →- MTH643 Handouts Complete by Mahar Afaq Safdar Muhammadi Handout PDF 12.5 MB
- MTH643 Midterm Past Paper Midterm PDF 46 KB
- MTH643 Solved Questions Lectures 1-8 Quiz PDF 610 KB
- MTH643 Final Term Quiz 3 by Wasi Quiz PDF 679 KB
- MTH643 Paper Code Solution Quiz PDF 157 KB
- MTH643 Quiz Lectures 12-15 Quiz PDF 9.8 MB
Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.