Skip to content

Latest commit

 

History

History
320 lines (221 loc) · 4.83 KB

File metadata and controls

320 lines (221 loc) · 4.83 KB

Do While Loop Program List

Note:

  • Give a STAR if you like this
  • FORK to get more update
  • Make a PULL REQUEST to countribute

Put your phone in desktop mode for easy access



TABLE OF ONE
```

#include <iostream>
using namespace std;
int main()
    {
        int i=1;
        do
        {
            printf("%d\n",i);
            i++;
        }
        while(i<=10);
    }


    /*
    ### Output ###
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    */

```

PRINT DIGITS OF INTEGER VALUE IN REVERSE ORDER
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b;
        cout<<"Enter any number\n";
        cin>>no;
        cout<<"Revere is given below\n";
        do
        {
            b=no%10;
            cout<<b;
            no=no/10;
        }
        while(no!=0);
    }


    /*
    ### Output ###
    Enter any number
    589
    Revere is given below
    985
    */

```

CHECK NUMBER IS PALINDROME OR NOT
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b,rev=0,cpy;
        cout<<"Enter any number\n";
        cin>>no;
        cpy=no;
        do
        {
            b=no%10;
            rev=rev*10+b;
            no=no/10;
        }
        while(no!=0)
        if(cpy==rev)
        cout<<"Palindrome";
        else
        cout<<"Not Palindrome";
    }


    /*
    ### Output ###
    Enter any number
    5885
    Palindrome
    */

```

FIND SUM OF DIGITS OF INTEGER VALUE
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b,sum=0;
        cout<<"Enter any number\n";
        cin>>no;
        do
        {
            b=no%10;
            sum=sum+b;
            no=no/10;
        }
        while(no!=0);
        cout<<"Total sum of digits="<<sum;
    }


      /*
    ### Output ###
    Enter any number
    785
    Total sum of digits=20
    */

```

MULTIPLY OF DIGITS OF INTEGER NUMBER
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b,m=1;
        cout<<"Enter any number\n";
        cin>>no;
        do
        {
            b=no%10;
            m=m*b;
            no=no/10;
        }
        while(no!=0)
        cout<<"Total multiply of digits="<<m;
    }


      /*
    ### Output ###
    Enter any number
    325
    Total multiply of digits=30
    */

```

PRINT FIRST AND LAST DIGIT OF INTEGER NUMBER
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b,f;
        cout<<"Enter any number\n";
        cin>>no;
        last=no%10;
        do
        {
            b=no%10;
            no=no/10;
        }
        while(no!=0);
        cout<<"First digit="<<b<<" and last digit="<<last;
    }


      /*
    ### Output ###
    Enter any number
    4859
    First digit=4 anda last digit=9
    */

```

CHECK GIVEN NUMBER IS ARMSTRONG NUMBER OR NOT
```

#include <iostream>
using namespace std;
int main()
    {
        int no,b,sum=0,copy;
        cout<<"Enter any number\n";
        cin>>no;
        copy=no;
        do
        {
            b=no%10;
            sum=sum+(b*b*b);
            no=no/10;
        }
        while(no!=0)
        if(copy==sum)
        cout<<"Number is Armstrong";
        else
        cout<<"Number is not Armstrong";
    }


      /*
    ### Output ###
    Enter any number 
    153
    Number is Armstrong
    */

```




Note:

  • Give a STAR if you like this
  • FORK to get more update
  • Make a PULL REQUEST to countribute