Revision of Class 9 Loops
Revision of Class 9 Loops
Loops
Assignment 1
------------------------------------------------------------------------------
General Instructions:-
1. The following assignments (unless otherwise mentioned) are meant to be done
in your school notebook.
2. Please use a giant ruled notebook (non-interleafed) as your computer
applications c.w. / h.w. notebook.
3. This assignment is to be submitted in the first computer class once the school
reopens.
----------------------------------------------------------------------------------------------------
1) State two differences between:
a. break and continue keywords.
b. for and do while loops.
2) State the output of the following snippets:
a. int i,j;
for (i=1;i<=5;++i)
{for(j=1;j<=3;j+=2)
System.out.print(++i*j--);
System.out.println();
}
b. int i,j,s=0;
for (i=1;i<=5;i+=2)
{for(j=3;j>=i;j--);
s+=j-i;
}
System.out.print(s);
c. int k=23;
while((k=k-3)>k/2)
{if(k==12)
continue
else if (k==5)
break;
System.out.println(k--);
}
System.out.println(++k);
3) Write the following programs in Java.
a. Design a program to print all the upper case English letters with prime
ASCII values.
b. Design a program to print the following pattern using nested loops.
1#
2@3#
4@5#6@
7#8@9#10@