- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AINeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
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,316,899 total executions (44,329 this month)
Practice C++ with coding challenges
Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.
Learn and practise C/C++
Follow a learning path with runnable lessons, then test yourself with coding challenges.
- C/C++ fundamentals
- C/C++ practice problems
- Pointers and memory
- Data structures and algorithms in C/C++
- Algorithms in C/C++
- Modern C++ features
- Programming fundamentals (C++)
- C++ coding challenges
- Online GDB Debugger
- AI Code Checker
- Run on CodeUtility button
- AI Code Generator
Popular lessons
🧩 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.
- Select a version and edit the current file or open another workspace file.
- Run the code, provide input in the terminal when requested, and review saved run history.
- 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.
- Set one or more breakpoints beside the line numbers.
- Select Debug to compile and pause at the first matching breakpoint.
- Inspect the current line, call stack, and variables.
- Use Continue, Step Over, Step Into, or Step Out to control execution.
- 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.