0% found this document useful (0 votes)
2 views

Class 001 Introduction and Installation

This document is a tutorial for beginners on C programming, covering the basics of programming languages, specifically C, and how to install necessary software like compilers and code editors. It explains the process of translating C code into machine code using a compiler and provides step-by-step instructions for writing and running a simple C program. Additionally, it discusses the limitations of using Notepad for coding and introduces more user-friendly code editors such as Code::Blocks and Visual Studio Code.

Uploaded by

rowshonara.338
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Class 001 Introduction and Installation

This document is a tutorial for beginners on C programming, covering the basics of programming languages, specifically C, and how to install necessary software like compilers and code editors. It explains the process of translating C code into machine code using a compiler and provides step-by-step instructions for writing and running a simple C program. Additionally, it discusses the limitations of using Notepad for coding and introduces more user-friendly code editors such as Code::Blocks and Visual Studio Code.

Uploaded by

rowshonara.338
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Author: Md.

Ashraful Islam, Lecturer, CSE, BUET

C Programming Tutorial for Beginners

Class 1: Introduction and Installation of Required Software

What is a Programming Language?

Programming language is a way to communicate instructions to a computer. Just like


humans use languages like English or Bengali, programmers use languages like C, Python,
or Java to tell computers what to do.

What is C?

C is one of the oldest and most powerful programming languages. It was developed in the
early 1970s by Dennis Ritchie at Bell Labs. It’s a procedural language that provides low-
level access to memory and is used in systems programming (like operating systems,
embedded systems).

How Do Machines Recognize Code?

Computers can only understand machine code – a sequence of 0s and 1s (binary). Human-
readable code (like C) needs to be translated into machine code so that the computer can
execute it.

How C Code is Translated to Machine Code (Compiler)

A compiler is a special program that translates your C code into machine code. Here's how
it works:

1. You write a C program (.c file).

2. The compiler translates it into an executable (.exe) or binary file.

3. The machine runs the binary file.

The most common C compilers are:

• GCC (GNU Compiler Collection)


Author: Md. Ashraful Islam, Lecturer, CSE, BUET

• Clang

• Turbo C (old)

• MSVC (Microsoft)

How to Install a C Compiler and Set the Environment Path

Installing GCC Compiler on Windows

1. Install TDM-GCC or MinGW (GCC version for Windows).

2. During installation, note the install path (e.g., C:\TDM-GCC-64\bin).

3. Add this path to the Environment Variable:

o Open Control Panel > System > Advanced system settings > Environment
Variables.

o Edit the Path variable under System variables.

o Add the path where gcc.exe is located.

4. Open Command Prompt and run gcc --version to confirm it's installed.

Write a Sample C Code in Notepad

#include <stdio.h>

int main() {

printf("Hello, World!\n");

return 0;

Save and Run It from Command Prompt

Step-by-step:

1. Save the file as hello.c using Notepad.


Author: Md. Ashraful Islam, Lecturer, CSE, BUET

2. Open Command Prompt.

3. Navigate to the folder where hello.c is saved using cd command:

4. cd C:\Users\YourName\Desktop

5. Compile the program:

6. gcc hello.c -o hello.exe

7. Run the program:

8. hello

You should see:

Hello, World!

Limitations of Using Notepad

• No syntax highlighting.

• No auto-completion or code suggestions.

• No error checking or debug support.

• Not beginner friendly.

Introduction to Code Editors

Code Editors make programming easier by providing:

• Syntax highlighting

• Autocomplete

• Error detection

• Integration with compiler/debugger

Examples:

• Code::Blocks (Free)

• VS Code (Free)

• CLion (Paid)
Author: Md. Ashraful Islam, Lecturer, CSE, BUET

How to Install Code::Blocks

1. Go to https://www.codeblocks.org/downloads/

2. Download the version with mingw-setup (includes compiler). (Direct Download Link)

3. Install it with default settings.

4. Open Code::Blocks → Create a new file.

Working with Code::Blocks

1. Create a new file.

2. Write the following code and save it (Ctrl+S) as test.c.

#include <stdio.h>

int main() {

printf("Hello, World!\n");

return 0;

3. Click Build and Run (F9).

4. Your program will compile and show output in the terminal window.

How to Install Visual Studio Code (VS Code)

1. Go to https://code.visualstudio.com/

2. Download and install for your OS.

3. Install the C/C++ extension from Microsoft (in Extensions panel).

4. Install Code Runner extension (optional).

Working with VS Code


Author: Md. Ashraful Islam, Lecturer, CSE, BUET

1. Create a folder and open it in VS Code.

2. Save your code as main.c.

3. Make sure GCC is installed and added to the PATH.

4. Open Terminal > New Terminal.

5. Compile and run:

6. gcc main.c -o main

7. ./main

Or use Code Runner to compile and run automatically.

You might also like