- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
In the program below, we've asked user to enter any number in decimal to convert it into octal, in C++
Source Code: Decimal to Octal Conversion
/* C++ Program - Decimal to Octal Conversion */ #include<iostream.h> #include<conio.h> void main() { clrscr(); long int decnum, rem, quot; int i=1, j, octnum[100]; cout<<"Enter any decimal number : "; cin>>decnum; quot=decnum; while(quot!=0) { octnum[i++]=quot%8; quot=quot/8; } cout<<"Equivalent octal value of "<<decnum<<" is : \n"; for(j=i-1; j>0; j--) { cout<<octnum[j]; } getch(); }Output
Enter any decimal number :50 Equivalent octal value of 50 is : 62