Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

ProgramsC++

Advanced Number Programs

Advanced C++ number programs: strong, neon, and narcissistic checks, powers, compound interest, digit reversal, and conversions between binary, octal, and decimal.

13 programs · open one, then the next

Start with Check Strong Number
  1. 01Check Strong NumberIntermediateCheck for a strong number in C++, where the factorials of the digits add up to the number itself. Traces 145 step by step and explains the factorial helper.Open example →
  2. 02Calculate Power of a NumberBeginnerUse pow(base, exponent) from <cmath> to raise numbers to any power in C++, including fractional and negative exponents. Covers NaN, inf, and rounding.Open example →
  3. 03Compound Interest: Precision and Compounding PeriodsBeginnerRevisit yearly compound interest in C++ with a focus on accuracy: float vs double, checking pow with a year-by-year loop, and changing the compounding frequency.Open example →
  4. 04Reverse a Number: Trailing Zeros and OverflowBeginnerReverse an integer's digits in C++ and test the inputs that break it: trailing zeros that vanish, negative numbers, and reverses too big for a 32-bit int.Open example →
  5. 05Convert Binary to DecimalIntermediateConvert a binary number typed as digits like 1010 into decimal in C++ by multiplying each bit by a power of 2. Covers the long long input trick and its limits.Open example →
  6. 06Convert Decimal to BinaryIntermediateConvert a decimal integer to binary in C++ by dividing by 2 and collecting remainders. Shows how remainders stack into a long long and where that runs out.Open example →
  7. 07Convert Octal to DecimalIntermediateConvert an octal number like 12 into decimal in C++ by multiplying each digit by a power of 8. Explains octal place values and why digits 8 and 9 are invalid.Open example →
  8. 08Convert Decimal to OctalIntermediateConvert a decimal integer to octal in C++ by dividing by 8 and collecting remainders. Compare the loop with cout << oct and see how 10 becomes 12.Open example →
  9. 09Convert Binary to OctalIntermediateConvert binary to octal in C++ by going through decimal with two helper functions. Learn the three-bit grouping shortcut and the type limits of this approach.Open example →
  10. 10Convert Octal to BinaryIntermediateConvert octal to binary in C++ by converting to decimal first and then to binary with two helpers. Includes the digit-to-three-bits shortcut for checking answers.Open example →
  11. 11Check Neon NumberIntermediateCheck whether a number is a neon number in C++: square it, add the digits of the square, and compare. Traces 9 (81 → 8 + 1 = 9) and covers overflow of the square.Open example →
  12. 12Check Narcissistic NumberIntermediateCheck for a narcissistic number in C++: count the digits, then add each digit raised to that count. Traces 153 and shows where pow rounding can bite.Open example →
  13. 13Convert Char to IntBeginnerTurn a digit character like '5' into the integer 5 in C++ eight ways, from ch - '0' to stoi and isdigit checks, then build 12345 from a char array.Open example →