Skip to content

Coding Practice

Solve problems in the built-in C++ compiler. Use hints only when stuck: they reveal ideas, not solutions.

Personal greeting

beginner
outputinput

Read a person's first name and print "Hello, <name>!".

sample input
Ada
expected output
Hello, Ada!

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Sum of two numbers

beginner
inputoperators

Read two integers and print their sum.

sample input
7 5
expected output
12

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Rectangle area and perimeter

beginner
operatorsvariables

Read width and height (integers). Print the area on the first line and the perimeter on the second.

sample input
4 3
expected output
12
14

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Celsius to Fahrenheit

beginner
type conversion

Read a temperature in Celsius (may have decimals) and print it in Fahrenheit.

sample input
25
expected output
77

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Even or odd

intermediate
conditionsoperators

Read an integer and print "even" or "odd".

sample input
17
expected output
odd

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Sum of digits

intermediate
loopsnumber problems

Read a non-negative integer and print the sum of its digits.

sample input
4096
expected output
19

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

FizzBuzz

intermediate
loopsconditions

Read n. For each i from 1 to n print Fizz if divisible by 3, Buzz if by 5, FizzBuzz if both, otherwise i.

sample input
5
expected output
1
2
Fizz
4
Buzz

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Prime check

advanced
loopsnumber problems

Read n (n ≥ 1) and print "prime" or "not prime".

sample input
29
expected output
prime

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →

Reverse a word

advanced
strings

Read one word and print it reversed, without using std::reverse.

sample input
stack
expected output
kcats

Run it in the built-in C++ compiler

Write your solution in our online compiler (GCC or Clang, C++17/20/23). The sample input is filled in for you, so you can compare your output with the expected output.

Open the compiler →