Q:

C++ Program To Print A Given Pattern Or Series Like 12345,5432,234,43,3

0

Write C++ Program To Print A Given Pattern Or Series Given Below .

12345
5432
234
43
3
 
Or Series Like :-12345 , 5432,234,43,3

Logic :- 
First Calculate A Length Digit Like 12345 Has 5 Digit By Using ( dig=log10 )After That Enter A Number To Reverse A Digit After That Divide By 10  Repeat The Process Again And Again .

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int i,j,p=1,n,reverse;

int main()
{
  cout<<"Enter The Number To Print A Pattern\n";
  cin>>n;
  int dig=log10(n);

   cout<<"\n"<<n<<endl;  
  
  for(i=1;i<=dig;i++)
  {
   while (n != 0)
     {
        reverse = reverse * 10;
        reverse = reverse + n%10;
        n       = n/10;
     }
     n=reverse/10;
    cout<<n<<endl;
    reverse=0;
   }  
 return 0; 
}

 

Output:

Enter the No To Print A Pattern

12345678

 

12345678

8765432

234567

76543

3456

654

45

5

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

<< Write A C++ Program To Print Perfact Square Of Pro...