0% found this document useful (0 votes)
19 views6 pages

IT Workshop 2

Uploaded by

Anubhab Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

IT Workshop 2

Uploaded by

Anubhab Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

IT Workshop (MATLAB) – PCCCS382

Assignment No: 1

Problem Statement
Write a program in MATLAB to find the sum of first 10 natural numbers

Understanding of problem statement


Initialize sum = 0. Start a loop from I = 1 to 10 and add every element to the sum. Display the
output.

Implemented code

Output

Name: Prarthita Kuri Class Roll No: 19

Enrollment No: 12023052002019 Stream: CSE

Section: A
Problem
Write a program in MATLAB to find the factorial of 21.

Understanding of problem statement


Initialize fact = 1. Start a for loop from i= 1 to 21 and multiple every element with fact. Display
the factorial.

Implemented code

Output

Name: Prarthita Class Roll No:

Enrollment No: Stream:

Section:
Problem
Write a program in MATLAB to if a given n umber is even or odd.

Understanding of problem statement


Take a input of a number. On dividing the number with 2, if the remainder is 0, then the
number is even, else, the number is odd.

Implemented code

Output

Name: Prarthita Class Roll No:

Enrollment No: Stream:

Section:
Problem
Write a program in MATLAB to check if 2023 is a leap year.

Understanding of problem statement


Take input of the year. Use the function leapyear(<year>) to find if the year is a leap year.

Implemented code

Output

Name: Prarthita Class Roll No:

Enrollment No: Stream:

Section:
Problem
Write program in MATLAB to print the following pattern
*
**
***

****

Understanding of problem statement


Take a loop x= 1 to 4 and one inner loop y= 1 to x and print *. The outer loop runs from 1 to n
and represents the rows of the triangle.The inner Loop runs from 1 to the current row number
(i.e., the row number of the outer loop) and prints *.
The fprintf function is used for printing without automatically moving to a new line after each
print.
The disp function can be used to move to a new line after printing a row.

Output

Name: Prarthita Class Roll No:

Enrollment No: Stream:

Section:
Problem Statement
Write program in MATLAB to print the following pattern
54321
4321
321

21
1

Understanding of problem statement

Name: Prarthita Class Roll No:

Enrollment No: Stream:

Section:

You might also like