0% found this document useful (0 votes)
0 views

Class IX Iterations (1)

Uploaded by

Krish Nawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Class IX Iterations (1)

Uploaded by

Krish Nawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CLASS : IX

Subject : Computer Applications


Topic : Loops -do while, conversions, jump statements

Name………………………………………… Sec………. Date……………

1. Explain the following:


a. Empty loop
b. Infinite loop
c. Jump statements
2. Give one similarity and one difference between
1. for and while loop.
2. break and continue
3. Determine the output of the following snippets:
a. int x = 0;
while(x- - > - 5)
System.out.println(x);
System.out.println(x);

b. int a,b;
for(a = -10, b = 10; a < b; a += b, b -= a)
System.out.println(a+" "+b);
System.out.println(a+" "+b);

c. a= 10;
b = 3;
do{
System.out.println(a+" "+b);
} while(a-->++b);
System.out.println(a+" "+b);

4. Rewrite the following program using for loop:


public class change{
public static void main(String args[])
{ int b=0;
String word= “Computer Applications”;
System.out.println( “the output is”);
do
{
System.out.println(word);
b=b+1;
} while(b<=4);
}
}
5. Rewrite the program using while loop

public class change1


{
Public static void main(String args[] )
{
int i,b=0,c;
for(i=1;i<=10;i++, b++)
{ c=b*b;
System.out.println(c);
}
}
}

6. Define a class to check whether a given number is an Abundant number or not.


[use do while loop]
Abundant numbers are numbers whose sum of all proper divisors is more than the number.
Example:
Abundant Number:
12: Divisors- 1,2,3,4,6 Sum = 1+2+3+4+6 = 16>12
40: Divisors- 1,2,4,5,8,10,20 Sum = 1+2+4+5+8+10+20 = 50>40
Not Abundant Number:
15: Divisors- 1,3,5 Sum = 1+3+5 = 9<15
.

You might also like