-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathreplace.java
More file actions
30 lines (27 loc) · 737 Bytes
/
replace.java
File metadata and controls
30 lines (27 loc) · 737 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
import java.util.*;
class replace
{
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
System.out.println("Enter the number of elements in array");
int n=obj.nextInt();
System.out.println("Enter the array");
int i;
int a[]=new int[100];
for(i=0;i<n;i++)
{
a[i]=obj.nextInt();
}
System.out.println("Enter the position to be changed");
int c=obj.nextInt();
System.out.println("Enter the element at the position");
int x=obj.nextInt();
a[c-1]=x;
System.out.println("New array:");
for(i=0;i<n;i++)
{
System.out.println(a[i]);
}
}
}