Octal to Decimal number program C++
Write the Octal to Decimal number program in C++.
Flowchart of Octal to Decimal number program C++
C++ Program to Convert Octal Number to Decimal number
Write the Octal to Decimal number program in C++ using the do-while loop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include<iostream> #include<math.h> using namespace std; int main() { int decimal_number=0 , remainder, octal_number; int count; cout<<"Enter an octal number:"; cin>> octal_number; count=0; do { remainder =
octal_number%10; decimal_number = decimal_number+ remainder*pow(8,count); octal_number=octal_number/10; count++; } while(octal_number>0); cout<<"decimal equivalent of"<<decimal_number; return 0; } |
loop | What lines will execute |
T | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  11, 12, 13, 14, 15, 16, 17, 18, 11,…… |
F | 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,11,17,18,19, 20, 21 |