Write C++ program to print all natural numbers in reverse order


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int num=0, i;
  7.  
  8. //Reading number
  9. cout<<"Enter any number: "<<endl;
  10. cin>>num;
  11. /*Running loop from the number entered by user,
  12.   and Decrementing by 1*/
  13. for(i=num; i>=1; i--)
  14. {
  15. cout<<i;
  16. }
  17. return 0;
  18.  
  19. }
  20.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts