+ 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 ответов
+ 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 🇮🇳