0% found this document useful (0 votes)
19 views6 pages

Sixth Batch Programming Assignment

The document outlines a programming assignment focused on creating various patterns using nested loops in different programming languages. It includes tasks that require the user to input a number and print specific patterns or sequences, such as stars or numbers, based on that input. Additionally, it introduces concepts like digital roots, prime numbers, happy numbers, and Niven numbers, providing a comprehensive set of exercises for practicing nested loops.

Uploaded by

rrt75940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views6 pages

Sixth Batch Programming Assignment

The document outlines a programming assignment focused on creating various patterns using nested loops in different programming languages. It includes tasks that require the user to input a number and print specific patterns or sequences, such as stars or numbers, based on that input. Additionally, it introduces concepts like digital roots, prime numbers, happy numbers, and Niven numbers, providing a comprehensive set of exercises for practicing nested loops.

Uploaded by

rrt75940
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Programming Assignment

Sixth Batch
Nested Loop

In the following questions your have to write a program to draw a given pattern with a special character
for instance a ‘*’ or any other you like. These questions must be done in a programming language and
not pseudocodes. Use a for loop or a while loop. It is a good idea to use name of row for the outer index.
One example is solved that you can take help from.

Example Question: Input a number N and print a pattern as shown. For instance if the input is 5 the
output should be

******

******

******

******

******

It is a square of the special chracter ‘*’ with 5 (N) rows and 5 (N) columns.

The solution in python is

num = int(input("Enter a number "))

for row in range(0,num):

line = ""

for col in range(0,num):

line = line + " * "

print(line)
The solution in VB.NET is
row = 0

while row < N

col = 0

while col < N

consolo.write(“ * “)

col = col + 1

end while

console.writeline()

row = row + 1

end while

Task # 57 : input a number N and print the shown pattern for example N = 5

**

***

****

*****

Task # 58 :

*****

****

***

**

*
Task # 59:

**

***

****

*****

****

***

**

Task # 60

*****

****

***

**

**

***

****

*****

Task # 61: Input a number N. Print

22

333

4444

55555
Task # 62 Input a number N , say 5

12

123

1234

12345

Task # 63: Input a number N say 5

12345

1234

123

12

Task # 64: Input a number N say 5

12

123

1234

12345

1234

123

12

==========================================================================
*********************** increasing difficulty level of nested loops *****************

===========================================================================

Task # 65 : Input a number N say 5

***** Print spaces in a controlled


loop for this pattern.
****

***

**

Task 66: Input a number say 5

*****

****

***

**

**

***

****

*****

Task # 67 : Input a number say 5

23

456

7 8 9 10

11 12 13 14 15
============================================================================

********************* ****Enough with patterns, but still nested *******************

============================================================================

Task # 68 : Input a number and print its digital Roots. A digit roots is the sum of its

digits until you get a one digits number for example

928758

9+2+8+7+5+8

39

3+9

12

1+2

3 is the digital root of the original number.

Task # 69 : Print the First 1000 Prime Numbers.

Taks # 70 : Input a number and print if it is a Happy number or Sad Number. A happy number is the one
which eventually reaches to 1 when replaced by sum of square of each digit. for example 13 is a happy
number as 1*1 + 3*3 = 10 and 1*1 + 0*0 = 1

but 15

1*1 + 5*5 = 26, 2*2 + 6*6 = 40, 4*4 + 0*0 = 16 ........................... think when you should stop.

Task # 71 : Input a number and print all Niven numbers/Harshad Number below

this number. A number N is Niven number if N is completly divisble but the sum of its

digits for example 18 is a Niven number because 18 is divisible by 9(sum of 1 and 8).

You might also like