Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Q1:

Display the following pattern:

ANS:
Algorithm:
STEP1: START
STEP2: Input the height of the triangle
STEP3: a. Print spaces for the current row b.
Print asterisks for the current row
STEP4: Move to the next line
STEP5: END
Pseudocode:
1. START
2. Read height
3. for i = 1 to height
a. for j = 1 to height – i
i. Print " "
b. for L = 1 to 2 * i - 1
i. Print "*"
4. Move to the next line
5. END

RUN 1:
Q#2:
Display the following pattern

ANS:
Algorithm:
STEP1: START
STEP2: Input the height of the triangle
STEP3: a. Print spaces for the current row
b. Print asterisks for the current row 5
STEP4: Move to the next line
STEP5: END

Pseudocode:
1. START
2. Read height
3. for i = height to 1 step -1
a. for j = 1 to height - i i. Print " "
b. for k = 1 to 2 * i - 1 i. Print "*"
4. Move to the next line
5. END

RUN 2:

Q#3: : Write a program to pass two numbers to the function body and print the
greater number on the screen.

Ans:
Algorithm:
STEP1: START
STEP2: Input two numbers, num1 and num2.
STEP3: Call a function (find Greater) with num1 and num2 as arguments.
STEP4: In the function
a. Compare num1 and num2
b. Return the greater of the two
STEP5: Print the result.
STEP6: END

Pseudocode:
1. START
2. Read num1
3. Read num2
4. result = find Greater (num1, num2)
5. Print "The greater number is: " + result
Function find Greater (num1, num2):
if num1 > num2
return num1
else
return num2
6. END

RUN 3:
Q4:
Develop a C++ program to pass a number as argument to the function body. Print
the table of that number in function body

ANS:
Algorithm:
STEP1: START
STEP2: Input a number
STEP3: Call a function, passing the number as an argument.
STEP4: Loop from 1 to 10 and print the multiplication table.
STEP5: END

Pseudocode:
1. START
2. Read num
3. Call function printTable(num)
4. Function printTable(num)
a. for i = 1 to 10
i. Print num * i
5. END
RUN 4:
INSTITUTE OF SPACE AND
TECHNOLOGY

Introduction to Information Technology


Electrical Engineering Department

Lab Report No.7

Submitted to: Haroon Ibrahim


Submitted by: Mahnoor Zahid
Reg No:230401032
Batch: EE 22-A

You might also like