Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Computer Notes

Uploaded by

JK aluri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Computer Notes

Uploaded by

JK aluri
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Instructions to Students:

1. Write the chapter number and name in the index page.


2. Start the lesson – important points, on a new page.
3. Maintain single line space after each point.
4. Take care of the case sensitive words (uppercase and lowercase) while writing method names and
syntax.
5. Read/Refer Text Book for each lesson before taking notes into CW.
6. Solve the TB exercise in the rough book and execute the programs.

Class :10 Subject: Computer Applications

Ch 11 Nested for loops


(part of Bridge Course)
Important Points:

Nested loop means a loop statement inside another loop statement. That is why nested loops
are also known as “loop inside loop“.

Syntax for Nested for() loop:

for ( initialization; condition; increment ) {


for ( initialization; condition; increment ){

// statement of inside loop


}
// statement of outer loop
}
Example:
for(int i=1;i<=r; i++) // outer loop
{
for(int j=1;j<=r;j++) // inner loop
{
System.out.print("# ");
} // end of j loop
System.out.println();
} // end of i 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:

1. Write a Java program to generate the following Pattern

@@@@@

@@@@@

@@@@@

public class Pattern1 {

public void display() {

for(int i=1;i<=3;i++) {

for(int j=1;j<=5;j++) {

System.out.print(“@ ");

System.out.println();

2. Write a Java program to generate the following Pattern

12345

12345

12345

12345
public class Pattern2 {

public void display() {

for(int i=1;i<=4;i++) {

for(int j=1;j<=5;j++) {

System.out.print(j+ “ ");

System.out.println();

3. Write a Java program to generate the following Pattern

11111

22222

33333

44444

public class Pattern3 {

public void display() {

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

public class Pattern4 {

public void display() {

for(int i=1;i<=5;i++) {

for(int j=1;j<=i;j++) {

System.out.print(j+ “ ");

System.out.println();

Series: A group or number of similar or related things arranged in a row.

Programs:

1. Write a Java program to generate the following Series.

1 2 3 4 5…….. n

public class Series1 {

public void main(int n) {

for(int i=1;i<=n;i++) {

System.out.print ( i + “ " );

}
}

2. Write a Java program to generate the following Series.

1 2 4 8 16 32 ……….. (2^n)

public class Series2 {

public void main(int n) {

for(int i=0;i<=n;i++) {

System.out.print ( (int) Math.pow(2,i) + “ " );

3. Write a Java program to print the sum of the following series

s= 1! + 2! + 3!+................ N!

public class Series3 {

public void main(int n) {

for(int i=1;i<=n;i++) {

s= s+ fact(i);

System.out.println ( “Sum = \t”+ s );

private int fact(int k){

int f=1;

for(int i=k; i>=1; i--)

{ f=f*i; }

return f;
}

*********************

You might also like