0% found this document useful (0 votes)
45 views

Problem # 1

The document outlines 4 programming problems: 1) printing numbers not divisible by 6 using continue, 2) printing a pattern of asterisks based on user input using nested for loops, 3) printing prime numbers between 0-N entered by the user using break, and 4) drawing an inverted pyramid based on user input and tracking the number of pyramids drawn using for loops. The problems provide examples of using control flow statements like continue, break, and nested loops based on user input.

Uploaded by

Munir Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Problem # 1

The document outlines 4 programming problems: 1) printing numbers not divisible by 6 using continue, 2) printing a pattern of asterisks based on user input using nested for loops, 3) printing prime numbers between 0-N entered by the user using break, and 4) drawing an inverted pyramid based on user input and tracking the number of pyramids drawn using for loops. The problems provide examples of using control flow statements like continue, break, and nested loops based on user input.

Uploaded by

Munir Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PROBLEM # 1:

Write a program that prints all the numbers from 0 to 29 that are not divisible by 6. Use a
continue statement to implement your program.

PROBLEM # 2:

Write a program that makes use of nested for loops to print the following pattern.

Now modify your code and take input from the user as to how many asterisks (*) to place in
each row and how many rows to draw. Also ask the user which character he would like to print
in place of the asterisk (*). The new output may look like the following.

Again modify your code so that the user can run your program again and again until the user
does not enter q or Q character to quit the program.

PROBLEM # 3

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.
PROBLEM # 4

Make a program that should draw an inverted pyramid up to a user-defined limit. Ask user if
another pyramid needs to be drawn. Then keep a track of the number of times pyramid is
made? You must use for loop to implement the logic.

Example:

You might also like