Professional Documents
Culture Documents
=b) || (b<4))
for(i=5;i>=1;i--) System.out.println(“Incredible”+”\n”+”world”); System.out.println(a+b);
{ else if((a>b) && (b<5))
if(i%2==1) System.out.println(a*b);
continue; else
System.out.print(i+” “); System.out.println(a%b);
}
If i)a=16,b=12 ii)a=27,b=28
d) int i; e)Write the value of d:- f) int a,b;
for(i=5;i>10;i++) a=25,b=35,c=11; for(a=6,b=4;a<=24;a=a+6)
System.out.println(i); i)d=!(a==0||a>b || !(b<0)); {if(a%b==0)
System.out.print(i*4); ii)d=!(a>b)&&(a<b&&b>0); break;
}
System.out.println(a);
g)Rewrite the following loop using for loop: h) Write a statement in Java for i) Rewrite the following decision making
while (true) 1 2 statements using conditional operator:-
𝑟 +𝑥 3
3
System.out.print("*"); i)if(x>0) flag=1;
else flag=0;
ii)if(m==0)
System.out.print(“Hello”);
else System.out.print(“Good Day”);
j) Write java expression for the following:- k) rectify:- l) Rewrite using multiple branching
a)r=
√(𝑝−𝑎)(𝑝−𝑏)(𝑝−𝑐)
b)v=
5𝑥3+2𝑦 int max=(a>b)?(a>c)?a:b:c; statement:
3 𝑥+𝑦 if(code=’A’)
a=”Accountant”;
elseif(code==’c’||code==’G’)
a=”Grade-iv”;
else
a=”Financial Advisor”;
m) Rewrite using more than one –if:- n) Convert the following if-else-if o) Rewrite the following using
if(tm>250 && em>80 && mm>95) construct into switch case:- logical operators:-
e=’y’;else e=’N’; if(ch=’c’||ch==’C’) if(x>5)
c)Rewrite using ‘while’: Sytem.out.print(“COMPUTER”); if(x>y)
{m=1;n=0; else if(ch=’h’||ch==’H’) System.out.println(x+y);
for( ;m+n<19;n++) Sytem.out.print(“HINDI”);
{Sopln(“Hello”);m+=10;} else
System.out.print(“PHYSICAL
EDUCATION”);