C Get Started
1. Setting Up Your C Environment
To write and run C programs, you need a compiler. Some popular options:
Option 1: Install on Your PC
-
Windows: Install Code::Blocks or Dev-C++ (includes compiler).
Or install GCC via MinGW. -
Linux: GCC is usually pre-installed. Otherwise, install via:
-
Mac: Install Xcode Command Line Tools:
Option 2: Online Compilers
If you don’t want to install anything, you can use online C compilers:
2. Writing Your First C Program
Open your editor or online compiler and type this:
Explanation:
-
#include <stdio.h>→ Imports the standard library for input/output. -
int main()→ Entry point of every C program. -
printf()→ Function to display text. -
return 0;→ Ends the program successfully.
3. Compiling and Running C Programs
Using a Compiler
-
Save your file as
hello.c. -
Open terminal/command prompt.
-
Compile:
-
Run:
Using Online Compiler
-
Paste your code.
-
Click Run.
-
Output will show:
4. Basic C Syntax and Rules
-
Case Sensitive –
mainandMainare different. -
Every statement ends with
; -
Curly braces
{}– Define the start and end of a block. -
Comments:
5. Variables and Data Types
Variables store values in memory. Examples:
-
%d→ integer -
%f→ float -
%c→ char
6. Getting User Input
-
scanf()→ Reads input from user. -
&→ Address operator (stores input in the variable).
7. Next Steps After Getting Started
Once you’ve run your first programs, you can move on to:
-
Operators → +, -, *, /, %, etc.
-
Conditional Statements → if, else, switch
-
Loops → for, while, do-while
-
Functions → Breaking code into reusable parts
-
Arrays & Strings → Storing multiple values
-
Pointers → Direct memory access
-
Structures & File Handling → For advanced applications
