Computer Science, asked by aldoratter, 3 months ago

Write a program using for loop print out all number from 1 to 20 in reverse order

Answers

Answered by anindyaadhikari13
1

Required Answer:-

Question:

  • Write a program using for loop to print all numbers from 1 to 20 in reverse order.

Solution:

Here comes the program.

1. In Java.

public class Loop {

public static void main(String[] args) {

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

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

}

}

2. In Python.

for i in range(20,0,-1):

print(i,end=" ")

3. In C.

#include <stdio.h>

void main() {

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

printf("%d ", i);

}

4. In C++

#include <iostream.h>

using namespace std;

void main() {

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

cout << i << " ";

}

Algorithm:

  1. START
  2. Iterate a loop in the range a = 20 to 1.
  3. Display the value of a.
  4. STOP.

See the attachment for output ☑.

Attachments:
Similar questions