Online C Compiler & Debugger

Write, compile, run, and debug C online. Set breakpoints, inspect variables, and step through code with GDB in Server mode - no setup required.

🚀 1,291,316 total executions (18,746 this month)
Embed
Output

Practice C++ with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All C++ challenges
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

To-Do List

Keep a list of tasks: add them, mark them done, remove them and report what is still pending.

You'll learn Typed collectionsRecords
BeginnerSimulationStrings
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Hard

Word Break

Decide whether text can be split into dictionary words.

You'll learn Prefix DPString segmentation
AdvancedDynamic-programmingHackathonStrings
Easy

Count Pairs With a Sum

Count pairs of positions whose values add up to a target.

You'll learn Pairs of indexesAvoiding double counts
ArraysBeginnerLearning-pathNested-loops
Easy

Missing Number

Find the one number missing from 0..n.

You'll learn Arithmetic seriesSum difference trick
ArraysBeginnerStudent-beginnermath
Medium

K-th Smallest Element

Find the k-th smallest value without fully sorting.

You'll learn QuickselectPartitioning
AdvancedCompetitive-programmingSorting
Easy

Min and Max Together

Find the smallest and largest value in one pass.

You'll learn Single passMultiple return values
ArraysBeginnerFunctionsLearning-path

🧩 About This C Online Executor

The CodeUtility C Executor lets you write and run C programs directly in your browser - no installation or compiler setup required. It’s powered by a secure sandbox that supports real C standards, including C89, C99, C11, and the latest version.

This tool uses a real C compiler running in the cloud to compile and execute your code just like a native environment. You can easily test snippets, learn syntax, or practice writing complete programs with input and output.

It’s designed to help learners and developers quickly experiment with C fundamentals - such as data types, pointers, loops, functions, arrays, and structures - without needing to install any compiler or IDE.

More than a code runner

Use a multi-file editor, an isolated execution terminal, runtime-specific libraries, persistent workspaces, sharing, and real-time collaboration from the same executor.

How to use this executor?

Choose a runtime, open or create a file, write your code, and select Run. Output appears in the terminal, while signed-in users can keep files in a workspace, install libraries, and collaborate through shares.

  1. Select a version and edit the current file or open another workspace file.
  2. Run the code, provide input in the terminal when requested, and review saved run history.
  3. Use libraries, workspace tools, sharing, and chat when your task needs more than one snippet.

💡 C Basics & Examples You Can Try Above

1. Declaring Variables and Constants

C requires you to declare the type of each variable. Use #define or const to define read-only values.

int age = 30;
double pi = 3.14159;
char grade = 'A';
char name[] = "Alice";
bool isActive = 1; // true

// Constants
#define MAX_USERS 100
const char* COMPANY = "CodeUtility";

2. Conditionals (if / switch)

Use if, else if, and switch for decision making.

int x = 2;
if (x == 1) {
    printf("One\n");
} else if (x == 2) {
    printf("Two\n");
} else {
    printf("Other\n");
}

switch (x) {
    case 1:
        printf("One\n");
        break;
    case 2:
        printf("Two\n");
        break;
    default:
        printf("Other\n");
}

3. Loops

Use for, while, and do-while for repetition.

for (int i = 0; i < 3; i++) {
    printf("%d\n", i);
}

int n = 3;
while (n > 0) {
    printf("%d\n", n);
    n--;
}

4. Arrays

Arrays store multiple elements of the same type.

int numbers[3] = {10, 20, 30};
printf("%d\n", numbers[1]);

5. Structs

struct lets you group related data.

struct Person {
    char name[50];
    int age;
};

struct Person p = {"Alice", 30};
printf("%s is %d years old\n", p.name, p.age);

6. Console Input/Output

Use printf and scanf for console I/O.

char name[50];
printf("Enter your name: ");
scanf("%s", name);
printf("Hello, %s\n", name);

7. Functions

Functions encapsulate reusable logic. Declare return type, name, and parameters.

int add(int a, int b) {
    return a + b;
}

printf("%d\n", add(3, 4));

8. Pointers

Use pointers to store memory addresses and manipulate data indirectly.

int x = 10;
int* ptr = &x;

printf("Value of x: %d\n", x);
printf("Address of x: %p\n", ptr);
printf("Value from pointer: %d\n", *ptr);

*ptr = 20;
printf("Updated x: %d\n", x);

9. File I/O

Use fopen, fprintf, fscanf, and fclose for file operations.

FILE* file = fopen("file.txt", "w");
fprintf(file, "Hello File");
fclose(file);

char line[100];
file = fopen("file.txt", "r");
fgets(line, sizeof(line), file);
printf("%s", line);
fclose(file);

10. String Handling

Use functions from <string.h> like strlen, strcpy, and strcmp.

#include <string.h>

char text[] = "Hello";
char copy[10];

strcpy(copy, text);
printf("Length: %lu\n", strlen(copy));
printf("Compare: %d\n", strcmp(copy, "Hello"));

11. Dynamic Memory

Use malloc and free for heap allocation.

int* nums = (int*) malloc(3 * sizeof(int));
nums[0] = 1; nums[1] = 2; nums[2] = 3;

for (int i = 0; i < 3; i++) {
    printf("%d ", nums[i]);
}

free(nums);

🐞 How to Debug %{language} Code Online

Use the online %{language} debugger to find runtime and logic errors without installing a compiler or desktop IDE. Server mode compiles with debug symbols and runs the program under GDB.

  1. Set one or more breakpoints beside the line numbers.
  2. Select Debug to compile and pause at the first matching breakpoint.
  3. Inspect the current line, call stack, and variables.
  4. Use Continue, Step Over, Step Into, or Step Out to control execution.
  5. Select Stop to end the debugging session.

Start with a small reproducible example and place a breakpoint just before the value or control flow becomes unexpected.