A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C++ to convert a decimal number to octal number
Q:

Write a program in C++ to convert a decimal number to octal number

0

Write a program in C++ to convert a decimal number to octal number

Sample Output:

 Convert a  decimal number to octal number:                            
-----------------------------------------------                        
 Input a decimal number: 15                                            
 The octal number is: 17

All Answers

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

#include <iostream>
#include <math.h>
using namespace std;
 
int main()
{
    int dec_num, rem, quot, i=1, j;
    int oct_num[100];
	cout << "\n\n Convert a  decimal number to octal number:\n";
	cout << "-----------------------------------------------\n";
	cout << " Input a decimal number: ";
	cin>> dec_num;
        quot = dec_num;
        while(quot != 0)
        {
            oct_num[i++] = quot % 8;
            quot = quot/8;
        }
		
        cout<<" The octal number is: ";
        for(j=i-1; j>0; j--)
        {
            cout<<oct_num[j];
        }
		cout<<"\n";	
} 

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now