Write a program using for loop print out all number from 1 to 20 in reverse order
Answers
Answered by
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:
- START
- Iterate a loop in the range a = 20 to 1.
- Display the value of a.
- STOP.
See the attachment for output ☑.
Attachments:
Similar questions
Social Sciences,
1 month ago
Math,
1 month ago
Math,
1 month ago
Science,
9 months ago
Math,
9 months ago