C++ Program to Convert Decimal to Octal

Master C++ with Real-time Projects and Kickstart Your Career Start Now!!

Program 1

// Decimal to Octal Conversion
#include<iostream>
#define clrscr() system("cls")
using namespace std;

int main()
{
      int d,oct[100],i,r;
      clrscr();
      cout<<"\nEnter decimal number";
      cin>>d;
      i=0;
      //Conversion of decimal to octal
      while(d!=0)
      {
           r=d%8;
          oct[i]=r;
          d=d/8; 
          i++;
      }
      i--;
      cout<<"\n\n Octal Number: ";
      while(i>=0)
      {
        cout<<oct[i];
        i--;
      }
      return 0;
}

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *