CS110: Fundamentals of Computer Programming
Class: BSCS-9AB
Lab 7: Nested Loops
Date: 23rd October, 2019
Time: 10am- 1pm & 2:00pm-5:00pm
Instructor: Ms Sana Khalique
Learning Objectives
After completing this section you will be able to create a program using nested loops
Basic Lab Instructions!
• You may want to bring your textbook to future labs to look up syntax and examples.
• Stuck? Confused? Have a question? Ask a TA/Lab Engineer for help, or look at the
book or past lecture slides.
• Complete as many problems as you can within the allotted time.
• Before you leave today, make sure to check in with one of the Lab Engineers/TAs in
the lab to get credit for your work.
Lab Tasks
Task#1:
Basic Nested Loops
Use some simple nested for loops to generate all possible coordinates from (0,0) up to (5,5).
Name the program BasicNestedLoops.c. Your output must appear in rows and columns as
follows.
Task#2:
Write a program that takes a number (N) from the user and prints all the prime numbers
between 0 – N. Try to use break statement in your program.
Task#3:
Number Puzzles
Use nested for loops to generate a list of all the pairs of positive two digit numbers whose
sum is 60, and whose difference is 14. Name the program NumberPuzzles1.c.
Task#4:
Write a C program which prints the following pattern of stars using nested loops. You are
not required to make the boxes
* *
* *
* *
* *
*
* *
* *
* *
* *
Hand in
Hand in the source code from this lab at the appropriate location on the blackboard
system at LMS. You should hand in a single compressed/archived file that contains all the
source files
If “winzip” software is not working then please copy the code of five tasks in one word file
and upload on LMS
To Receive Credit
1. By showing up on time for lab, working on the lab solution, only then you can
receive full credit for the lab assignment.
2. Comment your program heavily. Intelligent comments and a clean, readable
formatting of your code account for 20% of your grade.
3. In-class lab time is not intended as free time for working on your program
assignments. Only if you have completely solved the lab assignment, including all
challenges, and have had your work checked off for completeness by your TA/Lab
Engineer should you begin the program assignment.