3.0 University logo
  • Home
  • About us
  • All Courses
    • Cybersecurity Programs
      • Certified Ethical Hacker (CEH v13)
      • Certified SOC Analyst
      • Certified Penitration Testing Professional
      • Computer Hacking Forensic Investigator
      • Certified Cybersecurity Technician (CCT)
      • Certified AI Program Manager
      • Certified Offensive AI Security Professional
      • Certified Responsible AI Governance & Ethics Professional
      • Artificial Intelligence Essentials
    • Crypto Market Programs
    • Blockchain & Web3 Programs
      • Digital Assets Trading & Analysis Program
      • Certified Web3 Strategy & Growth Specialist
      • Certified Web3 Governance & Compliance Expert
      • Full Stack Blockchain Developer Program
      • Private Blockchain Developer Program
      • Public Blockchain Developer Program
    • IGM x IIG Programs
      • Jewellery Design Executive Program
      • Gems & Diamond Specialist Program
      • Jewellery Business Specialist Program
  • Schools
    • School of Decentralized Economics
    • School of Cyber Resilience
    • School of Intelligent Systems
    • School of Design Thinking
  • Partners
    • Certification & Knowledge Partner
    • Academic Partner
    • Hiring Partner
    • Delivery Partner
    • Affiliate Partner
    • Hybrid Center Partner
  • Blog
  • Home
  • About us
  • All Courses
    • Cybersecurity Programs
      • Certified Ethical Hacker (CEH v13)
      • Certified SOC Analyst
      • Certified Penitration Testing Professional
      • Computer Hacking Forensic Investigator
      • Certified Cybersecurity Technician (CCT)
      • Certified AI Program Manager
      • Certified Offensive AI Security Professional
      • Certified Responsible AI Governance & Ethics Professional
      • Artificial Intelligence Essentials
    • Crypto Market Programs
    • Blockchain & Web3 Programs
      • Digital Assets Trading & Analysis Program
      • Certified Web3 Strategy & Growth Specialist
      • Certified Web3 Governance & Compliance Expert
      • Full Stack Blockchain Developer Program
      • Private Blockchain Developer Program
      • Public Blockchain Developer Program
    • IGM x IIG Programs
      • Jewellery Design Executive Program
      • Gems & Diamond Specialist Program
      • Jewellery Business Specialist Program
  • Schools
    • School of Decentralized Economics
    • School of Cyber Resilience
    • School of Intelligent Systems
    • School of Design Thinking
  • Partners
    • Certification & Knowledge Partner
    • Academic Partner
    • Hiring Partner
    • Delivery Partner
    • Affiliate Partner
    • Hybrid Center Partner
  • Blog
    Login
    ₹0.00 0 Cart

    Learn Articles

    • Home
    • Learn Articles

    How to Write, Compile and Run a C Program (Step by Step)

    • Posted by 3.0 University
    • Date August 16, 2026
    • Comments 0 comment

    To run a C program, save your code as a .c file, compile it with GCC using gcc hello.c -o hello, then execute it with ./hello on Linux/Mac or hello.exe on Windows. The whole process takes under five minutes once your compiler is installed.

    • Key Takeaway 1: GCC (via MinGW on Windows) is the go-to compiler for beginners. It’s free, widely supported, and used in most Indian university syllabi.
    • Key Takeaway 2: You only need three things: a text editor, a compiler, and a terminal. VS Code bundles all three cleanly.
    • Key Takeaway 3: The compile command and the run command are two separate steps. Mixing them up is the most common beginner mistake.
    • Key Takeaway 4: C is still actively used in embedded systems, operating systems, and competitive programming, so learning it has real career value in 2026.
    • Key Takeaway 5: Most “gcc not recognised” errors on Windows are a PATH configuration problem, not a broken installation.

    Set Up a Compiler and Editor Before You Write a Single Line

    You cannot run a C program without a compiler. A compiler translates your human-readable C code into machine code the CPU can actually execute. That is what a compiler in C programming does at its core: it reads your .c file and produces a binary executable.

    GCC (GNU Compiler Collection) is the industry standard. It is what IIT and NIT lab manuals reference, it is what most open-source projects use, and it is free. According to the Stack Overflow Developer Survey 2024, C remains among the top 15 most-used programming languages globally, with particular strength in systems programming and competitive coding communities.

    Installing GCC on Windows with MinGW

    On Windows, GCC does not come natively. You install it through MinGW (Minimalist GNU for Windows), which packages GCC for Windows environments. Download the MinGW installer from mingw-w64.org, run it, and select the gcc and g++ packages.

    After installation, you must add MinGW’s bin folder to your Windows PATH. Open System Properties, go to Environment Variables, find the Path variable under System variables, click Edit, and add the path to your MinGW bin folder (usually C:\MinGW\bin). Restart your terminal after doing this.

    Installing GCC on Linux and Mac

    On Ubuntu or any Debian-based Linux, open a terminal and run sudo apt install gcc. On macOS, run xcode-select –install to get Apple’s Clang compiler, which is GCC-compatible for all beginner and intermediate use cases.

    Verify the installation on any OS by running gcc –version in your terminal. If you see a version number, you are ready to write and run a C program.

    What Is C Programming Used For Today?

    C is not a legacy language sitting in a museum. It powers the Linux kernel, embedded firmware in IoT devices, real-time systems in automotive and aerospace, and the internals of databases like PostgreSQL. According to the TIOBE Index (June 2025), C holds a top-3 position in programming language popularity, ahead of JavaScript in several consecutive months.

    In India specifically, C is a mandatory subject in B.Tech and BCA programs across AICTE-affiliated colleges. It is also a core language in GATE CS preparation and competitive programming on platforms like Codeforces. If you are thinking about career paths after 12th grade in 2026, a solid foundation in C gives you a head start in almost every engineering stream.

    C Compiler and Editor Options by Platform
    Platform Compiler/Tool Best For Cost
    Windows MinGW (GCC) Beginners, college labs Free
    Linux (Ubuntu) GCC (apt package) Developers, open-source work Free
    macOS Clang (Xcode CLI tools) Mac users, GCC-compatible Free
    Online (any OS) OnlineGDB, Replit Quick testing, no install needed Free (basic)
    Windows/Linux/Mac VS Code + C/C++ Extension Full projects, debugging Free

    How to Run a C Program: Command Prompt and Terminal Steps

    This is the core skill. Everything else, VS Code, IDEs, build systems, sits on top of this basic workflow. Once you understand how to run a C program from the command line, every other tool makes sense immediately.

    Step 1: Write Your First C Program

    Open any text editor (Notepad on Windows, gedit or nano on Linux) and type the following:

    #include <stdio.h>
    int main() {
        printf("Hello, World!\n");
        return 0;
    }

    Save the file as hello.c. The .c extension tells the compiler this is a C source file. Save it somewhere easy to find, like your Desktop or a folder called C_Programs.

    Step 2: Compile the Program with GCC

    Open Command Prompt (Windows) or Terminal (Linux/Mac). Navigate to the folder where you saved hello.c using the cd command. For example: cd Desktop\C_Programs on Windows, or cd ~/Desktop/C_Programs on Linux/Mac.

    Now compile it:

    gcc hello.c -o hello

    This tells GCC to compile hello.c and output an executable named hello. If there are no errors, GCC runs silently and creates the executable in the same folder.

    Step 3: Run the Compiled Program

    On Linux or Mac, type: ./hello
    On Windows, type: hello.exe

    You will see Hello, World! printed in the terminal. That is how to run a C program successfully from scratch.

    How to Run a C Program in CMD: Troubleshooting Common Errors

    If things go wrong, here are the most common problems and their fixes:

    • “gcc is not recognised as an internal or external command”: MinGW is not in your PATH. Go back to the PATH setup step and restart your terminal.
    • “No such file or directory”: You are not in the right folder. Use cd to navigate to where hello.c is saved, then compile again.
    • Permission denied (Linux/Mac): Run chmod +x hello to give the file execute permission, then try ./hello again.
    • Compilation errors (syntax errors): GCC will print the line number where the error is. Check for missing semicolons, mismatched brackets, or typos in function names.
    • Program compiles but shows nothing: Make sure your printf statement ends with \n and that you have included #include <stdio.h> at the top.

    According to the JetBrains Developer Ecosystem Survey 2023, over 55% of C and C++ developers use a command-line compiler as part of their primary workflow, confirming that this terminal-based skill is genuinely practical and not just an academic exercise.

    How to Run a C Program in VS Code

    VS Code is the editor of choice for most Indian engineering students who want something between a raw text editor and a heavy IDE like Code::Blocks. It is lightweight, free, and has excellent extension support. The Stack Overflow Developer Survey 2024 ranked VS Code as the most popular development environment for the seventh consecutive year, used by over 73% of respondents globally, including a large share of Indian developers.

    Install the C/C++ Extension

    Open VS Code, click the Extensions icon on the left sidebar (or press Ctrl+Shift+X), search for C/C++, and install the extension published by Microsoft. This extension adds IntelliSense (auto-complete), syntax highlighting, and debugging support for both C and C++ files.

    You still need GCC installed separately. VS Code does not bundle a compiler. It uses the GCC you installed via MinGW (Windows) or apt/Xcode (Linux/Mac).

    Configure and Run Your Program in VS Code

    Open your hello.c file in VS Code. Open the integrated terminal with Ctrl+` and type the GCC command manually:

    gcc hello.c -o hello

    Then run ./hello or hello.exe directly in that terminal. For a more automated setup, go to Terminal > Configure Default Build Task, select C/C++: gcc build active file, and VS Code will create a tasks.json file. After that, pressing Ctrl+Shift+B compiles the current file automatically.

    How to Run a C++ Program in VS Code

    The process for C++ is almost identical. Write your code in a .cpp file instead of .c, and use g++ instead of gcc to compile:

    g++ hello.cpp -o hello

    Then run it the same way: ./hello on Linux/Mac or hello.exe on Windows. The VS Code C/C++ extension handles both languages with the same setup. If you are exploring programming languages for blockchain development, C++ is particularly relevant since many blockchain protocols are written in it.

    Which App Is Used for C Programming?

    For beginners, the top choices are VS Code (with the C/C++ extension), Code::Blocks, and Dev-C++. For quick practice without installation, OnlineGDB and Replit work well. In Indian college labs, Turbo C is still sometimes used, but it is outdated and not recommended for anything beyond legacy coursework. GCC-based setups are the professional standard and worth learning from day one.

    If you are a student who qualifies for GitHub’s student developer pack, you get access to several premium dev tools for free. The GitHub Education Program is worth exploring alongside your C learning journey.

    Working on projects that go beyond basic programs? Check out the cybersecurity projects for students on 3.0 University’s learning hub. Many of them involve C-level systems thinking and are a strong portfolio addition for Indian engineering students targeting product companies or government tech roles.

    Want to explore more programming topics and tools? The 3.0 University learning hub covers everything from foundational programming to advanced cybersecurity and AI.

    C programming is a skill that compounds. Every hour you spend understanding pointers, memory management, and compilation directly makes you better at understanding how operating systems, networks, and security tools actually work under the hood. If you want to turn that foundation into a career-ready skill set, explore the online certification courses at 3.0 University covering Cybersecurity, Ethical Hacking, AI, Blockchain, and Web3.

    Frequently Asked Questions

    How do I run a C program in Command Prompt?

    Open Command Prompt, navigate to your .c file’s folder using cd, compile with gcc hello.c -o hello, then run with hello.exe. If GCC is not recognised, MinGW is not in your Windows PATH. Add the MinGW bin folder to your PATH environment variable and restart the terminal. This is the standard way to run a C program in CMD on Windows.

    How do I run a C program in VS Code?

    Install VS Code and the Microsoft C/C++ extension, then install GCC via MinGW (Windows) or apt/Xcode (Linux/Mac). Open your .c file, launch the integrated terminal with Ctrl+`, and run gcc hello.c -o hello followed by ./hello or hello.exe. You can also configure a build task to automate the compile step with Ctrl+Shift+B.

    Which compiler should beginners install for C?

    GCC is the best choice for beginners. On Windows, install it via MinGW from mingw-w64.org. On Linux, use sudo apt install gcc. On macOS, run xcode-select –install to get Clang, which is fully compatible. All three are free and widely used in Indian university courses and competitive programming.

    How do I run a C program on Linux or Mac?

    Open a terminal, navigate to your file’s directory, compile with gcc hello.c -o hello, then run with ./hello. On Mac, use Clang via Xcode command-line tools. If you get a permission denied error on Linux, run chmod +x hello first. The workflow to run a C program is identical on both platforms.

    What is C programming used for today?

    C is used in operating system kernels (Linux, Windows internals), embedded systems, IoT firmware, real-time software, database engines, and competitive programming. It is a core subject in B.Tech and BCA programs across India’s AICTE-affiliated colleges. The TIOBE Index consistently ranks C in the top 3 most-used programming languages globally as of 2025.

    Last updated: August 2026. Reviewed by the 3University editorial team.

    • Share:
    3.0 University

    Previous post

    What Is Linear Programming? Problems, Methods and Examples
    August 16, 2026

    Next post

    How to Compile and Run a Java Program (CMD, Notepad, VS Code)
    August 16, 2026

    You may also like

    Free AI Certificate Course by Government of India
    FREE AI Course with Certificate Launched by Govt of India
    June 19, 2026
    Highest Paid Professions in India
    Highest Paid Profession in India
    June 12, 2026
    Cyber Security Course Eligibility
    Cyber Security Course Eligibility
    June 11, 2026

    Leave A Reply Cancel reply

    You must be logged in to post a comment.

    3.0 University is a pioneering academic initiative for creating a comprehensive knowledge ecosystem for emerging technologies. We have developed an in-house suite of course offerings for retail, institutional market participants and industry-at-large. 

    Facebook X-twitter Instagram Linkedin
    Quick Links
    • About us
    • Courses
    • Become a Partner
    • Contact Us
    • Blog
    • Learn
    Trending Courses
    • Certified SOC Analyst
    • Certified Ethical Hacker v13 Program
    • Certified Penitration Testing Professional
    • Full Stack Blockchain Developer
    • Certified AI Program Manager
    Policies
    • Privacy Policy
    • Terms and Conditions
    • Disclaimer
    • Refund Policy
    Contact Us
    FT Tower, CTS No. 256 & 257, Suren Road, Chakala, Andheri (E), Mumbai-400093 India.

    +91 8657961141

    support@3university.io

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now

    Sign In

    Welcome back! Or create an account

    OR
    Forgot password?

    Need a new verification email?

    Don't have an account? Register

    Create Account

    Already have an account? Sign in

    OR

    Already have an account? Log in

    Reset Password

    Enter your email and we'll send you a reset link.

    ← Back to login

    Check Your Email

    Almost there!
    We have sent a verification link to your email address. Please check your inbox (and spam folder) and click the link to activate your account.

    Didn't receive the email? Enter your address to resend:

    Already verified? Sign in