0% found this document useful (0 votes)
5 views7 pages

PFund Lab 6

The document outlines a lab focused on implementing for and nested for loops through various tasks, including generating even numbers, creating multiplication tables, and calculating factorials. It emphasizes the utility of for loops for fixed iterations and nested loops for complex tasks, while also noting performance considerations. The lab includes multiple examples and tasks to practice these concepts.

Uploaded by

huzaifamallhi64
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)
5 views7 pages

PFund Lab 6

The document outlines a lab focused on implementing for and nested for loops through various tasks, including generating even numbers, creating multiplication tables, and calculating factorials. It emphasizes the utility of for loops for fixed iterations and nested loops for complex tasks, while also noting performance considerations. The lab includes multiple examples and tasks to practice these concepts.

Uploaded by

huzaifamallhi64
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/ 7

Lab: 6

Objective:
Implementation Of for And Nested for Loops:
Example #1

Example #2
Example #3

Example #4
Lab Task
Task #1

Task #2

Task #3
Task #4
Write a program to generate a series of first 50 even numbers.
Task #5
Write a program that generates a table of any number.
Task #6
Write a program to calculate the factorial of any number.

SUMMARY:
 for loop: Ideal for iterating a fixed number of times. It’s simple, readable,
and efficient for many tasks where the number of iterations is known in
advance.
 Nested for loop: A powerful tool when you need to perform multiple
iterations for each step of an outer loop, such as when working with multi-
dimensional arrays or generating complex patterns. However, be cautious
with performance, especially with large inputs, since the time complexity
increases exponentially with each additional nested loop.

You might also like