write a program by for loop
Answers
I hope this is the standard example.
Sometimes we call the customer service via mobile, then it asks us to select an option from the menu. Upon selecting a menu item, we will be taken to concerned services. Here, if we don't select any services, it just hangs out. So the condition(menu) must be displayed, before its usage.
Ex:
char selection;
do{
System.out.println("Menu Items");
System.out.println("Press 1 for Mobile");
System.out.println("Press 2 for Data");
System.out.println("Press 3 for Complaints");
selection=(char) System.in.read();
}while(selection<'1' || selection>'3');
switch(selection){
case 1:
----
default:
}
Program to print following output
Output:
B
B L
B L U
B L U E
B L U E J
Explanation:
Following are the program in the Python Programming Language:
#set string type variable
str="BLUEJ"
#set for loop for row
for i in range(len(str)+1):
#set for loop for column
for j in range(i):
#print message with space
print(str[j], end=" ")
#for line break
print("\n")
Following are the description of the program:
- Firstly, set a variable 'str' and initialize the string data that variable.
- Set the two for loop for the row and column, the first for loop for the row and the second for loop for the column.
- Finally, print the output with space and then again use the print function to break the line for the following format.
Learn More:
brainly.in/question/8167037