-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ3(EP).java
More file actions
33 lines (27 loc) · 747 Bytes
/
Q3(EP).java
File metadata and controls
33 lines (27 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
3. To learn use of single dimensional array by defining the array is dynamically.
import java.util.Scanner;
public class prog3 {
public static void main(String args[]){
int a[]=new int[10],s;
Scanner scan =new Scanner(System.in);
System.out.println("enter the size of array: ");
s=scan.nextInt();
System.out.println("enter the elements of array: ");
for(inti=0;i<s;i++){
a[i]=scan.nextInt();
}
for(int x=0;x<s;x++){
a[x]=a[x]+5;
}
System.out.println("after adding 5 in each element: ");
for(int j=0;j<s;j++){
System.out.print(a[j]+" ");
}}}
Output -
enter the size of array:
2
enter the elements of array:
1
2
after adding 5 in each element:
6 7