Computer Notes
Computer Notes
Nested loop means a loop statement inside another loop statement. That is why nested loops
are also known as “loop inside loop“.
Jump Statements:
Jump statements are mainly used to transfer control to another part of our program depending
on the conditions. These statements allow alteration of the flow of execution of the program.
They can be used to jump directly to other statements, skip a specific statement and so on. In
Java we have the following three jump statements:
1. break
2. continue
3. return
Patterns: A repeated form or design that happens in a regular and repeated way.
Programs:
@@@@@
@@@@@
@@@@@
for(int i=1;i<=3;i++) {
for(int j=1;j<=5;j++) {
System.out.print(“@ ");
System.out.println();
12345
12345
12345
12345
public class Pattern2 {
for(int i=1;i<=4;i++) {
for(int j=1;j<=5;j++) {
System.out.print(j+ “ ");
System.out.println();
11111
22222
33333
44444
for(int i=1;i<=4;i++) {
for(int j=1;j<=5;j++) {
System.out.print(i+ “ ");
System.out.println();
}
4. Write a Java program to generate the following Pattern
12
123
1234
12345
for(int i=1;i<=5;i++) {
for(int j=1;j<=i;j++) {
System.out.print(j+ “ ");
System.out.println();
Programs:
1 2 3 4 5…….. n
for(int i=1;i<=n;i++) {
System.out.print ( i + “ " );
}
}
1 2 4 8 16 32 ……….. (2^n)
for(int i=0;i<=n;i++) {
s= 1! + 2! + 3!+................ N!
for(int i=1;i<=n;i++) {
s= s+ fact(i);
int f=1;
{ f=f*i; }
return f;
}
*********************