Arrays
Arrays
e )W h a t
is
the
codes
given ldentify the errors
of
Question2:. :
Some
Write the output
2, 29, 91;
them.
45, 4, 92,
andcorrect
=
=
5,
(25,
5, 4
25,+ad[7]1) /ad[5];
all
a d l ]
+ a
ap)
"
( a d / o
==
"+
+
Result
Result
int =
Sistenn.out.prin
i n ta p
int("
20, 30);
=
{10,
CQ[i]++; CQ[3]++;
CQll
nt
i n tC
CO]++;
3:j++)
<
= 0;j "+COljl);
, +CQlil):
or(intj
Svstem.out.print ("
77, 33, 55);
55};
{11, 44,
LP[] = <=4;j++)
int 0;j
or(intj
=
P[4] + LP14):
= +LP[4) "
LPil+=j =
System.outprint("
LP
5.57, 6.23, 7.25:
{3.12, 4.64,
double KB[]=
) j++)
intj 0;j <=5; =
for(
KBli] = (int)KBIjl;
=
"
+ KB[2]);
System.out.print("KB[2]
6.23, 7.25];
double FZ]
= {3.12, 4.64, 5.57,
e)
boolean asC =true;
<= 3; j++)
for( intj 0; j =
iH(FZIj]> FZj+1]))
asc false;
y'stem.out.print(" ASC =
"
+ asc);
int GY[= {3.12, 4.64, 5.57, 6.23, 7.25);
boolean desc true; =
GYj]>GY[j+1]) 335
desc false;
break;
"
+ desc);
System.out.print(" DESC
=
652, 782 ;
g) int YM[]= {512, 312, 452,
boolean all = true;
if(YM[j1%10 = 2)
all false;
"+ all);
Svstem.out.print("ALL
=
if (MW[j]/100 > 0)
(i) In the above code hi), replace the array by int MW[ ] {56, 21, 33, 78, 95
=
() int ZR[] =
{0,0, 0, 0, 0,0, 0};
ZR[O] = 2;
for(int j 1;j < ZR.length; j++)
=
Clength; ji s)
0i
m.nil.print(" " + H C
4HClil);
11/ 1 ,22,,3
22 33, 44, 55, 66, 77
I1.length 1;
l i - 0 1 n / 2 ;j+4)
f
WHil
1ntH/-W7l/n
m -il:
iln- tmp;
stem.out.print(" +WHil);
12=
new
int[5];
0;j<=nj++)
7int j =
sistem.out.print(" "+DL[j]);
:oid main)
Sring SN[]
=
("D", "E", "F", "R", "O", "S", "T", "E", "D";
int n = SN.length;
1;j=j +1)
intj =0;j<=SN.length
-
for
System.out.printn();
"LIA ;
"RIA", "ICE", "LAND", "MONG0,
gCNIJ=|"SIBE",
int n= CN.length;
torlintj 0; ji<=n-2;j++)
=
ifj %2 1=0)
337
Continue;
System.out.print(" "+WKDlil);
ifWKDil.charAt(0) == "T)
System.out.println(" ");
String SNI] = ("A", "B", "C", "D", "E", "F", "G", "H";
int n =
SN.length;
for(intj =n-1;j >=0;j =j-1)
System.out.println(" * " +SN[il);
ifj % 2 != 0)
continue;
r e m p l e :
TAI 21 31 41 51 61 23
Input:
43
TBI1 28 38 48 58 68 78 16
utput: TT[ ]| 28 38 48 58 68 78 16
21 31 41 51 61 23 43
Create dString
Stri array SR[ J of size 7, Store the weekdays in it. Input an
integer, weekDa DayNum and print the corresponding weekDayName. Note
that
nst day of a Week is "SUNDAY". Check validity range of input.
Forexample:
Input weekDayNum: 2
Output: weekDayName: MONDAY
Input: weekDayNum 9