+ 2

Why it’s not print welcome as much as input taken

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); for(n=0;n<10;n++){ System.out.println("Welcome"); } } }

8th Nov 2021, 2:06 PM
āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āĻ¨āĻžāĻœāĻŽā§āĻ˛ āĻ‡āĻ¸āĻ˛āĻžāĻŽ
āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āĻ¨āĻžāĻœāĻŽā§āĻ˛ āĻ‡āĻ¸āĻ˛āĻžāĻŽ - avatar
3 Answers
+ 3
You mean input number of to print? If yes, then it prints 10 times only for what ever input. Because you are replacing n value to 0 in start of loop n=0 Take other variable 'i' and make condition like I<n for( int i=0; i<n ; i++){ .. }
8th Nov 2021, 2:37 PM
Jayakrishna 🇮đŸ‡ŗ
+ 1
Jayakrishna🇮đŸ‡ŗ Thank You ❤ī¸ I got the output
8th Nov 2021, 2:50 PM
āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āĻ¨āĻžāĻœāĻŽā§āĻ˛ āĻ‡āĻ¸āĻ˛āĻžāĻŽ
āĻŽā§‹āĻšāĻžāĻŽā§āĻŽāĻĻ āĻ¨āĻžāĻœāĻŽā§āĻ˛ āĻ‡āĻ¸āĻ˛āĻžāĻŽ - avatar
+ 1
You're welcome..
8th Nov 2021, 2:52 PM
Jayakrishna 🇮đŸ‡ŗ