WAP to display your name 20 names on different time, using for statement
Answers
Hello friend, I wrote your answer in python.
name = input("What's your name? ")
print(*(name for i in range(10)), sep='\n')
Hope this Helps buddy :)
Java Programming
We'll be using loop to print the name on the screen for 20 times.
loop in java is used to execute a specific set of statements a fixed number of times.
The syntax for the lop is:
for (initialization; testCondition; update)
{
// statements inside the body of the loop
}
The Program
public class Main // Creating class
{
// The MAIN function
public static void main(String[] args) {
// Using for loop to print a name 20 times
for (int i = 1; i <= 20; i++)
{
// Printing the name on the screen
System.out.println("lHello World");
}
}
}
Program Explanation
In the above program, is the initialization statement which is executed only once.
is the test condition of the loop. The loop ends when it's false.
is the update statement. It is equivalent to .