0% found this document useful (0 votes)
2 views4 pages

Do While Loop

The document contains several Java programs that utilize do-while loops to perform various tasks. These include printing numbers in descending order, generating odd and even number sequences, creating specific patterns, and printing multiplication tables. Each program is structured within a public class and demonstrates the use of the do-while loop for iterative operations.

Uploaded by

P21
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)
2 views4 pages

Do While Loop

The document contains several Java programs that utilize do-while loops to perform various tasks. These include printing numbers in descending order, generating odd and even number sequences, creating specific patterns, and printing multiplication tables. Each program is structured within a public class and demonstrates the use of the do-while loop for iterative operations.

Uploaded by

P21
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

DO-WHILE LOOP PROGRAMS

//Write a program to print numbers from 10-1 in descending 10


order public class Prgd2 9
{ 8
public void main() 7
{ 6
int i=10; 5
do 4
{ 3
[Link](i); 2
i--; 1
}
while(i>=1);
}
}

//Write a program to print the odd numbers from 1-19 using do-while 1
loop public class Prgd3
3
{
5
public void main()
{ 7
int i=1; 9
do 11
{ 13
[Link](i); 15
i+=2; 17
}
19
while(i<=19);
}
}
//Write a program to print the even numbers from 2-20 using do- while 2
loop 4
public class Prgd4 6
{ 8
10
public void main() 12
{ 14
int i=2; 16
do 18
{ 20
[Link](i);
i+=2;
}
while(i<=20);
}
}

/*Write a program to generate the following pattern using do-while loop


5 10 15 20 ------50 */

public class Prgd5


{
public void main()
{
int i=5;
do
{
[Link](i+" ");
i+=5;
}
while(i<=50);
}
}

Output: 5 10 15 20 25 30 35 40 45 50
/*Write a program to generate the following pattern using do-while loop
1 2 3 -------- 10*/

public class Prgd6


{
public void main()
{
int i=1;
do
{
[Link](i+" ");
i++;
}
while(i<=10);
}
}

Output: 1 2 3 4 5 6 7 8 9 10

Write a pgm to print the multiplication table of a Output( if we pass n as 6)


number passed as argument 1*6=6
public class prgdw7 2*6=12
{ 3*6=18
4*6=24
public void accept (int n) 5*6=30
{ 6*6=36
Int i=1; 7*6=42
do 8*6=48
{ 9*6=54
[Link](i+”* “+n+”=”+i*n); 10*6=60
i++;
}
while(i<=10);
}
}

You might also like