CJCoding With Joseph
TitleTopicsAction
145
Throw on Division by ZeroComplete the `safeDivide` function below. If `b` is 0, throw a `std::runtime_er...
easy○ Not Started
FunctionsExceptions
Solve
146
Catch a Runtime ErrorThe function `riskyDivide` below already throws a `std::runtime_error` when `b` ...
easy○ Not Started
FunctionsExceptions
Solve
147
Validate Age with ExceptionComplete the `validateAge(int age)` function. - If `age` is less than 0, throw ...
easy○ Not Started
FunctionsExceptions
Solve
150
Validate Test ScoreComplete the `validateScore(int score)` function. - If `score` is less than 0 o...
easy○ Not Started
FunctionsExceptions
Solve
244
Square a NumberWrite a function `int square(int n)` that returns n multiplied by itself. The p...
easy○ Not Started
Functions
Solve
245
Cube a NumberWrite a function `int cube(int n)` that returns n raised to the third power (n t...
easy○ Not Started
Functions
Solve
246
Maximum of Two NumbersWrite a function `int maxOf(int a, int b)` that returns the larger of the two va...
easy○ Not Started
Functions
Solve
247
Minimum of Two NumbersWrite a function `int minOf(int a, int b)` that returns the smaller of the two v...
easy○ Not Started
Functions
Solve
248
Absolute ValueWrite a function `int absVal(int n)` that returns the absolute value of n (its d...
easy○ Not Started
Functions
Solve
249
Check if a Number Is EvenWrite a function `bool isEven(int n)` that returns true when n is even and false...
easy○ Not Started
Functions
Solve
250
Sum from 1 to NWrite a function `int sumTo(int n)` that returns the sum of all integers from 1 ...
easy○ Not Started
Functions
Solve
251
Factorial FunctionWrite a function `long long factorial(int n)` that returns n! (the product of al...
easy○ Not Started
Functions
Solve
252
Celsius to FahrenheitWrite a function `int toFahrenheit(int celsius)` that converts a Celsius tempera...
easy○ Not Started
Functions
Solve
253
Rectangle Area FunctionWrite a function `int area(int width, int height)` that returns the area of a re...
easy○ Not Started
Functions
Solve
254
Check if a Number Is PositiveWrite a function `bool isPositive(int n)` that returns true when n is greater th...
easy○ Not Started
Functions
Solve
255
Double a NumberWrite a function `int doubleIt(int n)` that returns n multiplied by 2. For doub...
easy○ Not Started
Functions
Solve
393
Average of Three NumbersWrite a function `double average(int a, int b, int c)` that returns the average ...
easy○ Not Started
Functions
Solve
394
Fahrenheit to CelsiusWrite a function `double toCelsius(double f)` that converts a Fahrenheit tempera...
easy○ Not Started
Functions
Solve
395
Circle Area FunctionWrite a function `double area(double r)` that returns the area of a circle using...
easy○ Not Started
Functions
Solve
396
Multiply Two NumbersWrite a function `int multiply(int a, int b)` that returns the product of `a` an...
easy○ Not Started
Functions
Solve
397
Check if a Number Is OddWrite a function `bool isOdd(int n)` that returns `true` when `n` is odd and `fa...
easy○ Not Started
Functions
Solve
398
Convert Kilometers to MilesWrite a function `double toMiles(double km)` that converts kilometers to miles b...
easy○ Not Started
Functions
Solve
399
Void Function to GreetWrite a `void` function named `greet` that takes no parameters and prints exactl...
easy○ Not Started
Functions
Solve
400
Compute Simple InterestWrite a function `double simpleInterest(double p, double r, double t)` that retu...
easy○ Not Started
Functions
Solve
401
Maximum of Three NumbersWrite a function `int maxOfThree(int a, int b, int c)` that returns the largest ...
easy○ Not Started
Functions
Solve
402
Hypotenuse FunctionWrite a function `double hypotenuse(double a, double b)` that returns the hypote...
easy○ Not Started
Functions
Solve
403
Percentage FunctionWrite a function `double percentage(int obtained, int total)` that returns the p...
easy○ Not Started
Functions
Solve
404
Compute BMIWrite a function `double bmi(double weight, double height)` that returns the Bod...
easy○ Not Started
Functions
Solve
405
Sum of Squares from 1 to NWrite a function `int sumOfSquares(int n)` that returns `1*1 + 2*2 + ... + n*n`....
easy○ Not Started
Functions
Solve
151
Multiple Catch BlocksWrite two functions that demonstrate catching different exception types: 1. `pr...
medium○ Not Started
FunctionsExceptions
Solve
154
Rethrowing ExceptionsWrite two functions that demonstrate logging and rethrowing an exception: 1. `l...
medium○ Not Started
FunctionsExceptions
Solve
256
Power FunctionWrite a function `long long power(int base, int exp)` that returns base raised t...
medium○ Not Started
Functions
Solve
257
Count the Digits of a NumberWrite a function `int countDigits(int n)` that returns how many digits a positiv...
medium○ Not Started
Functions
Solve
258
Letter Grade FunctionWrite a function `string letterGrade(int score)` that returns the letter grade f...
medium○ Not Started
Functions
Solve
259
Greatest Common DivisorWrite a function `int gcd(int a, int b)` that returns the greatest common diviso...
medium○ Not Started
Functions
Solve
406
Check Leap YearWrite a function `bool isLeapYear(int year)` that returns `true` if `year` is a ...
medium○ Not Started
Functions
Solve
407
Sum of an ArrayWrite a function `int sumArray(int arr[], int size)` that returns the sum of the...
medium○ Not Started
Functions
Solve
408
Swap Two Numbers by ReferenceWrite a function `void swapValues(int &a, int &b)` that swaps the two integers u...
medium○ Not Started
Functions
Solve
409
Function Overloading: AddWrite two overloaded functions both named `add`: one taking two `int`s and retur...
medium○ Not Started
Functions
Solve
410
Default Argument GreetingWrite a function `void greet(string name = "Guest")` that prints `Hello, ` follo...
medium○ Not Started
Functions
Solve
411
Recursive Sum of DigitsWrite a recursive function `int sumDigits(int n)` that returns the sum of the di...
medium○ Not Started
Functions
Solve
412
Count Vowels in a StringWrite a function `int countVowels(string s)` that returns the number of vowels (...
medium○ Not Started
Functions
Solve
413
Clamp a ValueWrite a function `int clampValue(int value, int low, int high)` that returns `lo...
medium○ Not Started
Functions
Solve
414
Palindrome Number CheckWrite a function `bool isPalindrome(int n)` that returns `true` if the digits of...
medium○ Not Started
Functions
Solve
260
Check if a Number Is PrimeWrite a function `bool isPrime(int n)` that returns true when n is a prime numbe...
hard○ Not Started
Functions
Solve
261
Nth Fibonacci NumberWrite a function `long long fib(int n)` that returns the nth Fibonacci number, w...
hard○ Not Started
Functions
Solve
262
Reverse the Digits of a NumberWrite a function `int reverseNumber(int n)` that returns a positive integer with...
hard○ Not Started
Functions
Solve
415
Lambda to Add Two NumbersUse a C++ lambda to add two numbers. Define a lambda stored in `auto add` that t...
hard○ Not Started
Functions
Solve
416
Function Pointer to Apply OperationWrite a function `int applyOp(int a, int b, int (*op)(int, int))` that calls the...
hard○ Not Started
Functions
Solve
417
Static Local CounterWrite a function `int nextId()` that uses a `static` local variable to return a ...
hard○ Not Started
Functions
Solve