I attempted to convert a base 10 number to a base 6 number in C, but my code failed two hidden test cases.

I don't see any logical flaws in it.

Could you do it?

```//convert base 10 to base 6

#include<stdio.h>
int main()
{
int num, rem = 0, i = 1, res = 0;
scanf("%d", &num);
while(num!=0)
{
rem = num%6;
res = (rem*i)+res;
num = num/6;
i = i*10;
}
printf("%d",res);

}
```
Jul 26, 2022 in C++ 532 views

## No answer to this question. Be the first to respond.

 Your name to display (optional): Email me at this address if my answer is selected or commented on: Privacy: Your email address will only be used for sending these notifications.

## How do i apply lower_bound to a range of unsorted vector elements?

What's the point of sorting your array? ...READ MORE

## Vector of Vectors to create matrix

Before accessing any elements, you must first set the vector of vectors to the right size.  You may do it this way: // assumes using std::vector for brevity vector<vector<int>> matrix(RR, ...READ MORE

## What does the C++ standard state the size of int, long type to be?

I'm seeking for specific information on the sizes of basic C++ types.  I understand that it is determined by the architecture (16 bits, 32 bits, or 64 bits) and the compiler. But are there any C++ standards? On a 32-bit architecture, I'm using Visual Studio 2008.  This is what I get: char : 1 byte short : 2 ...READ MORE

## What does the C++ standard state the size of int, long type to be?

I'm seeking for specific information on the sizes of basic C++ types.  I understand that it is determined by the architecture (16 bits, 32 bits, or 64 bits) and the compiler. But are there any C++ standards? On a 32-bit architecture, I'm using Visual Studio 2008.  This is what I get: char : 1 byte short : 2 ...READ MORE

## How to access static members of a class?

I'm learning C++ and Qt, but even the simplest code that I copy and paste from a book produces problems. On Ubuntu 10.04, I'm using g++4.4.2 with the QtCreator IDE.  Is there a distinction between the syntax of the g++ compiler and those of other compilers?  When I try to access static members, for example, something always goes wrong. #include <iostream> using namespace std; class A { ...READ MORE

## How to create a dynamic array of integers

How can I use the new keyword ...READ MORE

## C++ interview preparation

I am assuming that this phone interview ...READ MORE

## setuptools: build shared libary from C++ code, then build Cython wrapper linked to shared libary

There is a seemingly undocumented feature of setup that ...READ MORE