Online C Compiler
Write C code, press Run, and see the output in a few seconds. No sign-up, no install.
About this C compiler
This free online C compiler runs your program on our server with GCC 10. When your program calls scanf(), you type the input in the terminal, and you see the output, the errors and the time your program took.
It is a good fit for practice questions, college lab programs and quick tests before an exam or an interview.
How to use it
- Write your program in the editor. It must have a main() function.
- If your program reads input with scanf(), type it in the terminal when the program asks, and press Enter. You can also put it in the Input box before you press Run.
- Press Run. The output appears below the editor.
C examples
Open any of these from the Examples tab in the side bar.
Hello, World
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}
Sum of two numbers (with input)
#include <stdio.h>
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
printf("Sum = %d\n", a + b);
return 0;
}
Factorial with a loop
#include <stdio.h>
int main(void) {
long long result = 1;
for (int i = 1; i <= 10; i++) {
result *= i;
}
printf("10! = %lld\n", result);
return 0;
}
What is C?
C is one of the oldest programming languages that is still used every day. Operating systems, databases and small devices are written in C. Many Indian colleges teach C as the first language, because it shows how memory and the computer really work.
C is a compiled language. A compiler turns your code into a program first, and then the program runs. If the code has a mistake, the compiler stops and shows an error with a line number.
Common errors and how to fix them
error: expected ';' before …A semicolon is missing at the end of the line before the one shown.implicit declaration of function 'printf'Add #include <stdio.h> at the top of the file.Segmentation faultYour program used memory it does not own. Check array indexes and pointers.
Frequently asked questions
Which C compiler and version is used?
GCC 10.2. Your code is compiled with the default C standard of GCC 10, which supports C11 features.
Can my program read input?
Yes. Type the input in the terminal while the program runs, or put it in the Input box before you press Run. scanf(), getchar() and fgets() all read it.
Is there a time limit?
Yes. Without an account a program can use 3 seconds of computer time, and it can wait up to 30 seconds for your input. A loop that never ends is stopped and marked "Took too long".
Do I need to create an account?
No. The compiler is free and works without an account. With a free account you get higher limits: longer run time and bigger programs.
Can I use files or the internet from my program?
No. For safety, programs run in a sandbox with no network access. Read input from the terminal instead of files.
Other free compilers
Learn to code with DevHives
Step-by-step lessons, DSA problems with a judge and mock interviews — made for students in India.
Create a free account