| Title | Open | |||
|---|---|---|---|---|
| 145 | Throw on Division by ZeroComplete the safeDivide function below. | easy | Not started | Solve |
| 146 | Catch a Runtime ErrorThe function riskyDivide below already throws a std::runtime_error when b is 0. | easy | Not started | Solve |
| 147 | Validate Age with ExceptionComplete the validateAge(int age) function. | easy | Not started | Solve |
| 150 | Validate Test ScoreComplete the validateScore(int score) function. | easy | Not started | Solve |
| 244 | Square a NumberWrite a function int square(int n) that returns n multiplied by itself. | easy | Not started | Solve |
| 245 | Cube a NumberWrite a function int cube(int n) that returns n raised to the third power (n times n times n). | easy | Not started | Solve |
| 246 | Maximum of Two NumbersWrite a function int maxOf(int a, int b) that returns the larger of the two values. | easy | Not started | Solve |
| 247 | Minimum of Two NumbersWrite a function int minOf(int a, int b) that returns the smaller of the two values. | easy | Not started | Solve |
| 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. | easy | Not started | Solve |
| 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. | easy | Not started | Solve |
| 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 + ... | easy | Not started | Solve |
| 251 | Factorial FunctionWrite a function long long factorial(int n) that returns n! | easy | Not started | Solve |
| 252 | Celsius to FahrenheitWrite a function int toFahrenheit(int celsius) that converts a Celsius temperature to Fahrenheit using F = C 9 / 5 + 32. | easy | Not started | Solve |
| 253 | Rectangle Area FunctionWrite a function int area(int width, int height) that returns the area of a rectangle (width times height). | easy | Not started | Solve |
| 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). | easy | Not started | Solve |
| 255 | Double a NumberWrite a function int doubleIt(int n) that returns n multiplied by 2. | easy | Not started | Solve |
| 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. | easy | Not started | Solve |
| 394 | Fahrenheit to CelsiusWrite a function double toCelsius(double f) that converts a Fahrenheit temperature to Celsius using (f - 32) 5 / 9. | easy | Not started | Solve |
| 395 | Circle Area FunctionWrite a function double area(double r) that returns the area of a circle using 3.14159 r r. | easy | Not started | Solve |
| 396 | Multiply Two NumbersWrite a function int multiply(int a, int b) that returns the product of a and b. | easy | Not started | Solve |
| 397 | Check if a Number Is OddWrite a function bool isOdd(int n) that returns true when n is odd and false otherwise. | easy | Not started | Solve |
| 398 | Convert Kilometers to MilesWrite a function double toMiles(double km) that converts kilometers to miles by multiplying by 0.621371. | easy | Not started | Solve |
| 399 | Void Function to GreetWrite a void function named greet that takes no parameters and prints exactly the line shown in Expected Output. | easy | Not started | Solve |
| 400 | Compute Simple InterestWrite a function double simpleInterest(double p, double r, double t) that returns simple interest using p r t / 100. | easy | Not started | Solve |
| 401 | Maximum of Three NumbersWrite a function int maxOfThree(int a, int b, int c) that returns the largest of the three integers. | easy | Not started | Solve |
| 402 | Hypotenuse FunctionWrite a function double hypotenuse(double a, double b) that returns the hypotenuse length using sqrt(aa + bb). | easy | Not started | Solve |
| 403 | Percentage FunctionWrite a function double percentage(int obtained, int total) that returns the percentage obtained 100.0 / total. | easy | Not started | Solve |
| 404 | Compute BMIWrite a function double bmi(double weight, double height) that returns the Body Mass Index using weight / (height height). | easy | Not started | Solve |
| 405 | Sum of Squares from 1 to NWrite a function int sumOfSquares(int n) that returns 11 + 22 + ... | easy | Not started | Solve |
| 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. | easy | Not started | Solve |
| 721 | Split a Record on PipesA record holds fields separated by |, for example 9781|The Hobbit|3|12.50. | easy | Not started | Solve |
| 151 | Multiple Catch BlocksWrite two functions that demonstrate catching different exception types: 1. | medium | Not started | Solve |
| 154 | Rethrowing ExceptionsWrite two functions that demonstrate logging and rethrowing an exception: 1. | medium | Not started | Solve |
| 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. | medium | Not started | Solve |
| 257 | Count the Digits of a NumberWrite a function int countDigits(int n) that returns how many digits a positive integer n has. | medium | Not started | Solve |
| 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". | medium | Not started | Solve |
| 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). | medium | Not started | Solve |
| 406 | Check Leap YearWrite a function bool isLeapYear(int year) that returns true if year is a leap year. | medium | Not started | Solve |
| 407 | Sum of an ArrayWrite a function int sumArray(int arr[], int size) that returns the sum of the first size elements of arr. | medium | Not started | Solve |
| 408 | Swap Two Numbers by ReferenceWrite a function void swapValues(int &a, int &b) that swaps the two integers using reference parameters. | medium | Not started | Solve |
| 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. | medium | Not started | Solve |
| 410 | Default Argument GreetingWrite a function void greet(string name = "Guest") that prints Hello, followed by the name and a !. | medium | Not started | Solve |
| 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. | medium | Not started | Solve |
| 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. | medium | Not started | Solve |
| 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. | medium | Not started | Solve |
| 414 | Palindrome Number CheckWrite a function bool isPalindrome(int n) that returns true if the digits of n read the same forwards and backwards. | medium | Not started | Solve |
| 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. | hard | Not started | Solve |
| 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. | hard | Not started | Solve |
| 262 | Reverse the Digits of a NumberWrite a function int reverseNumber(int n) that returns a positive integer with its digits reversed. | hard | Not started | Solve |
| 415 | Lambda to Add Two NumbersUse a C++ lambda to add two numbers. | hard | Not started | Solve |
| 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. | hard | Not started | Solve |
| 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. | hard | Not started | Solve |