how to make this program with for loop and while loop

Write a simple c++ program that displays a range of numbers in reverse order according to your roll number i.e. if your roll number is 142090, take last two digits of your roll number (90) and print the numbers between higher numbers (9) to smaller number (0).
Please tell me what will be the code for this program.
and please tell me the code in for loop
This is my code please help me
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;
main()
{int a;
cout<<"Enter Roll no. : ";
cin>>a;
cout<<"\nReverse order"<<endl;
for(int i=a;i>=1;i--)
cout<<i<<endl;
	
}

Last edited on
Do you know about the mod operator (%)?
Topic archived. No new replies allowed.