-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam.java
More file actions
100 lines (76 loc) · 2.15 KB
/
Copy pathExam.java
File metadata and controls
100 lines (76 loc) · 2.15 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Find the leader elements in of an array.The elements the bigger than all list right side element in array
//! eg- i/p-[17,18,5,4,6,1]
//! o/p-18,6,1
import java.util.Arrays;
class TextDemo{
public static void main(String[]args){
int a[]={17,18,5,4,6,1};
}
static void m1(int...a){
for(int i=0;i<=a.length;i++){
if(a[i]%2==0){
System.out.println();
}
}
}
}
//! Wtite a program, wher the given input is sorted aray a[],and a key.find out sum of any two element.
//! same as given key or not .if possible return true other wise return false;
//! ip-[1,2,3,4,5,6,7,8] key=14
//! op- true, because 6+8=14
class Sorted{
public static void main(String[]args){
int a[]={1,2,3,4,5,6,7,8};
}
}
class ArrayPrime{
public static void main(String[]args){
int a[]= {1,2,3,4,5,6,7,8,9};
for(int temp:a){
if(isPrime(temp)){
System.out.println(temp);
}
}
}
static boolean isPrime(int n){
if(n<=1) return false;
int count=0;
for (int i=1;i<=n;i++){
if(n%i==0)
count++;
}
return count==2;
}
}
class UpdateValue{
public static void main(String[]args){
int a[]={3,2,1,4,3,5,4};
System.out.println(Arrays.toString(a));
m1(a,10,3);
System.out.println(Arrays.toString(a));
}
static void m1(int a[],int newValue,int oldValue){
for(int i=0;i<a.length;i++){
if(a[i]==oldValue){
a[i]=newValue;
}
}
}
}
//! write a program, where the given input String is pangram or not.
//! Astringis known as panagram if it contains all the character of english alphabate.
class Palindrome{
public static void main(String...args){
String s="madam";
String rev="";
for(int i= s.length()-1;i>=0;i--){
rev+=s.charAt(i);
}
if(s.equals(rev)){
System.out.println("Palindrome");
}
else{
System.out.println(" Not a Palindrome");
}
}
}