Write a program to generate the following output.
# @
@ #
@ # @
@ # @ #
@ # @ # @
Answers
Answered by
8
You mean:
@
@ #
@ # @
@ # @ #
@ # @ # @
Language:
Python
Program:
n=int(input())
for i in range(1,n+1):
for j in range(i):
if j%2==0:
print("@",end="")
else:
print("#",end="")
print()
Output:
Consider the attachment. (for program too)
Logic:
- I printed the regular numbers such that 1st of the number is even, then 2nd is odd and so on.
- I printed "@" in place of even numbers and "#" in place of odd numbers.
Attachments:
Similar questions