CJCoding With Joseph
15free / daySign inCreate account
TitleOpen
145
Throw on Division by ZeroComplete the safeDivide function below.
easyNot startedSolve
146
Catch a Runtime ErrorThe function riskyDivide below already throws a std::runtime_error when b is 0.
easyNot startedSolve
147
Validate Age with ExceptionComplete the validateAge(int age) function.
easyNot startedSolve
150
Validate Test ScoreComplete the validateScore(int score) function.
easyNot startedSolve
244
Square a NumberWrite a function int square(int n) that returns n multiplied by itself.
easyNot startedSolve
245
Cube a NumberWrite a function int cube(int n) that returns n raised to the third power (n times n times n).
easyNot startedSolve
246
Maximum of Two NumbersWrite a function int maxOf(int a, int b) that returns the larger of the two values.
easyNot startedSolve
247
Minimum of Two NumbersWrite a function int minOf(int a, int b) that returns the smaller of the two values.
easyNot startedSolve
248
Absolute ValueWrite a function int absVal(int n) that returns the absolute value of n (its distance from zero, always non-negative) WITHOUT using the library abs function.
easyNot startedSolve
249
Check if a Number Is EvenWrite a function bool isEven(int n) that returns true when n is even and false when it is odd.
easyNot startedSolve
250
Sum from 1 to NWrite a function int sumTo(int n) that returns the sum of all integers from 1 to n (1 + 2 + ...
easyNot startedSolve
251
Factorial FunctionWrite a function long long factorial(int n) that returns n!
easyNot startedSolve
252
Celsius to FahrenheitWrite a function int toFahrenheit(int celsius) that converts a Celsius temperature to Fahrenheit using F = C 9 / 5 + 32.
easyNot startedSolve
253
Rectangle Area FunctionWrite a function int area(int width, int height) that returns the area of a rectangle (width times height).
easyNot startedSolve
254
Check if a Number Is PositiveWrite a function bool isPositive(int n) that returns true when n is greater than 0, and false otherwise (zero is not positive).
easyNot startedSolve
255
Double a NumberWrite a function int doubleIt(int n) that returns n multiplied by 2.
easyNot startedSolve
393
Average of Three NumbersWrite a function double average(int a, int b, int c) that returns the average of the three integers as a double.
easyNot startedSolve
394
Fahrenheit to CelsiusWrite a function double toCelsius(double f) that converts a Fahrenheit temperature to Celsius using (f - 32) 5 / 9.
easyNot startedSolve
395
Circle Area FunctionWrite a function double area(double r) that returns the area of a circle using 3.14159 r r.
easyNot startedSolve
396
Multiply Two NumbersWrite a function int multiply(int a, int b) that returns the product of a and b.
easyNot startedSolve
397
Check if a Number Is OddWrite a function bool isOdd(int n) that returns true when n is odd and false otherwise.
easyNot startedSolve
398
Convert Kilometers to MilesWrite a function double toMiles(double km) that converts kilometers to miles by multiplying by 0.621371.
easyNot startedSolve
399
Void Function to GreetWrite a void function named greet that takes no parameters and prints exactly the line shown in Expected Output.
easyNot startedSolve
400
Compute Simple InterestWrite a function double simpleInterest(double p, double r, double t) that returns simple interest using p r t / 100.
easyNot startedSolve
401
Maximum of Three NumbersWrite a function int maxOfThree(int a, int b, int c) that returns the largest of the three integers.
easyNot startedSolve
402
Hypotenuse FunctionWrite a function double hypotenuse(double a, double b) that returns the hypotenuse length using sqrt(aa + bb).
easyNot startedSolve
403
Percentage FunctionWrite a function double percentage(int obtained, int total) that returns the percentage obtained 100.0 / total.
easyNot startedSolve
404
Compute BMIWrite a function double bmi(double weight, double height) that returns the Body Mass Index using weight / (height height).
easyNot startedSolve
405
Sum of Squares from 1 to NWrite a function int sumOfSquares(int n) that returns 11 + 22 + ...
easyNot startedSolve
720
Trim Spaces From Both EndsWrite the function string trim(const string& text) so it returns text with every space and tab removed from the START and the END only.
easyNot startedSolve
721
Split a Record on PipesA record holds fields separated by |, for example 9781|The Hobbit|3|12.50.
easyNot startedSolve
151
Multiple Catch BlocksWrite two functions that demonstrate catching different exception types: 1.
mediumNot startedSolve
154
Rethrowing ExceptionsWrite two functions that demonstrate logging and rethrowing an exception: 1.
mediumNot startedSolve
256
Power FunctionWrite a function long long power(int base, int exp) that returns base raised to the exp power, WITHOUT using the library pow function.
mediumNot startedSolve
257
Count the Digits of a NumberWrite a function int countDigits(int n) that returns how many digits a positive integer n has.
mediumNot startedSolve
258
Letter Grade FunctionWrite a function string letterGrade(int score) that returns the letter grade for a score: 90+ is "A", 80-89 is "B", 70-79 is "C", 60-69 is "D", below 60 is "F".
mediumNot startedSolve
259
Greatest Common DivisorWrite a function int gcd(int a, int b) that returns the greatest common divisor of a and b using the Euclidean algorithm (repeatedly replace the pair with b and a % b until b is 0).
mediumNot startedSolve
406
Check Leap YearWrite a function bool isLeapYear(int year) that returns true if year is a leap year.
mediumNot startedSolve
407
Sum of an ArrayWrite a function int sumArray(int arr[], int size) that returns the sum of the first size elements of arr.
mediumNot startedSolve
408
Swap Two Numbers by ReferenceWrite a function void swapValues(int &a, int &b) that swaps the two integers using reference parameters.
mediumNot startedSolve
409
Function Overloading: AddWrite two overloaded functions both named add: one taking two ints and returning their int sum, and one taking two doubles and returning their double sum.
mediumNot startedSolve
410
Default Argument GreetingWrite a function void greet(string name = "Guest") that prints Hello, followed by the name and a !.
mediumNot startedSolve
411
Recursive Sum of DigitsWrite a recursive function int sumDigits(int n) that returns the sum of the digits of a non-negative integer n.
mediumNot startedSolve
412
Count Vowels in a StringWrite a function int countVowels(string s) that returns the number of vowels (a, e, i, o, u, upper- or lowercase) in the string s.
mediumNot startedSolve
413
Clamp a ValueWrite a function int clampValue(int value, int low, int high) that returns low if value is below low, high if value is above high, and value otherwise.
mediumNot startedSolve
414
Palindrome Number CheckWrite a function bool isPalindrome(int n) that returns true if the digits of n read the same forwards and backwards.
mediumNot startedSolve
260
Check if a Number Is PrimeWrite a function bool isPrime(int n) that returns true when n is a prime number (a whole number greater than 1 whose only divisors are 1 and itself), and false otherwise.
hardNot startedSolve
261
Nth Fibonacci NumberWrite a function long long fib(int n) that returns the nth Fibonacci number, where fib(0) = 0, fib(1) = 1, and each later value is the sum of the previous two.
hardNot startedSolve
262
Reverse the Digits of a NumberWrite a function int reverseNumber(int n) that returns a positive integer with its digits reversed.
hardNot startedSolve
415
Lambda to Add Two NumbersUse a C++ lambda to add two numbers.
hardNot startedSolve
416
Function Pointer to Apply OperationWrite a function int applyOp(int a, int b, int (op)(int, int)) that calls the function pointed to by op with a and b and returns the result.
hardNot startedSolve
417
Static Local CounterWrite a function int nextId() that uses a static local variable to return a new id each time it is called: the first call returns 1, the second 2, and so on.
hardNot startedSolve