0% found this document useful (0 votes)
634 views5 pages

Pseudo Code For Factorial

The document contains pseudo code for calculating the factorial of a number, the areas of circles, rectangles, and squares, as well as pseudo code to determine the day of the week from a given number. Pseudo code is provided to declare variables, read input values, perform calculations, store results and display outputs for each problem.

Uploaded by

Chat
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)
634 views5 pages

Pseudo Code For Factorial

The document contains pseudo code for calculating the factorial of a number, the areas of circles, rectangles, and squares, as well as pseudo code to determine the day of the week from a given number. Pseudo code is provided to declare variables, read input values, perform calculations, store results and display outputs for each problem.

Uploaded by

Chat
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/ 5

Pseudo code for factorial

Begin

1: Declare an integer variable called n and Read number n.


2. Initialize i and set fact to 1.
3. Repeat step 4 and step 5 while i is not equal to n.
4. fact <- fact * i
5. i <- i +1
6. Return fact

End

Pseudo code for area of rectangle, circle and square

Area of circle

1: Begin

2: Set PI to 3.14

3: Read radius

4: Compute the product of radius with itself and PI value

5: Set the result to area

6: display Area

7. end

Area of rectangle

1: Begin

2: Read length and breadth

3: Compute the product of length and breadth

4: Set the result to area

5: display Area

6. end

Area of square

Area of rectangle
1: Begin

2: Read length

3: Compute the product of length with itself

4: Set the result to area

5: display Area

6. end

Pseudo code for week days

1.begin

2.read number n

3.
#include <stdio.h>

int main()

int a[10][10], b[10][10], result[10][10], r1, c1, r2, c2, i, j, k;

printf("Enter rows and column for first matrix: ");

scanf("%d %d", &r1, &c1);

printf("Enter rows and column for second matrix: ");

scanf("%d %d",&r2, &c2);

// Column of first matrix should be equal to column of second matrix and

while (c1 != r2)

printf("Error! column of first matrix not equal to row of second.\n\n");

printf("Enter rows and column for first matrix: ");

scanf("%d %d", &r1, &c1);

printf("Enter rows and column for second matrix: ");

scanf("%d %d",&r2, &c2);

// Storing elements of first matrix.

printf("\nEnter elements of matrix 1:\n");

for(i=0; i<r1; ++i)

for(j=0; j<c1; ++j)

printf("Enter elements a%d%d: ",i+1, j+1);

scanf("%d", &a[i][j]);
}

// Storing elements of second matrix.

printf("\nEnter elements of matrix 2:\n");

for(i=0; i<r2; ++i)

for(j=0; j<c2; ++j)

printf("Enter elements b%d%d: ",i+1, j+1);

scanf("%d",&b[i][j]);

// Initializing all elements of result matrix to 0

for(i=0; i<r1; ++i)

for(j=0; j<c2; ++j)

result[i][j] = 0;

// Multiplying matrices a and b and

// storing result in result matrix

for(i=0; i<r1; ++i)

for(j=0; j<c2; ++j)

for(k=0; k<c1; ++k)

result[i][j]+=a[i][k]*b[k][j];

// Displaying the result

printf("\nOutput Matrix:\n");
for(i=0; i<r1; ++i)

for(j=0; j<c2; ++j)

printf("%d ", result[i][j]);

if(j == c2-1)

printf("\n\n");

return 0;

You might also like