Computer Science, asked by gurvipatel13, 2 months ago

Write a java program to display the series 7,6,5,4,3,2,1 using for loop.

Answers

Answered by allysia
1

Language:

JAVA

Program:  

public class oh {

public static void main(String[] args) {

for (int i = 7; i > 0; i--)

{ System.out.print(i + " "); }

} }

Output:

Consider the attachment.

Explanation:

  • initialize value at as i =7
  • decrease it by 1 every time the loop runs as long as the value id greater than 0.

Attachment:

Attachments:
Answered by Anonymous
42

Required Answer :

Question:

  • Write a java program to display the series 7,6,5,4,3,2,1 using for loop.

Program:

This is the required Java program to display the series 7,6,5,4,3,2,1.

/*This is the required program to display the series 7,6,5,4,3,2,1*/

public class Serrev

{

public static void main (String args[])

{

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

{

System.out.print(k+"");

}

}

}

The output will be as follows:

7654321.

Attachments:
Similar questions