+ 1
import java.util.*; public class Program { public static void main(String[] args) { int arr[]; Scanner sc=new Scanner(System.in); System.out.println("enter the size of the array"); int s=sc.nextInt(); arr=new int[s]; } }
19th Jan 2017, 6:43 AM
Harsimran Kaur Bindra
Harsimran Kaur Bindra - avatar
0
You can't declare an array with variable size in C unless you (re)allocate the memory manually as far as I know. For java you can just define the array (int array[];) and then declare it later (array = new int[size];) with size being for example a number entered by the user.
19th Jan 2017, 5:30 AM
Robobrine
Robobrine - avatar