+ 1

Error is coming in this program

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

26th May 2022, 3:09 AM
Sonam
Sonam - avatar
1 Answer
+ 2
Sonam Check this adaptation of your code to see if it suits import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); for(int i=0;i<x;i++){ System.out.println(x); } } }
26th May 2022, 5:18 AM
Rik Wittkopp
Rik Wittkopp - avatar