100% found this document useful (1 vote)
5 views

Intro to Programming Week 1

This document outlines the curriculum for BCSC 1102: Intro to Programming, focusing on the C programming language. It covers the history, features, applications, and environment setup for C programming, including IDEs and compilers. Additionally, it provides a step-by-step guide for writing and running a basic C program.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5 views

Intro to Programming Week 1

This document outlines the curriculum for BCSC 1102: Intro to Programming, focusing on the C programming language. It covers the history, features, applications, and environment setup for C programming, including IDEs and compilers. Additionally, it provides a step-by-step guide for writing and running a basic C program.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

BCSC 1102 : Intro To Programming Week 1

Dr. Shem Mbandu Angolo, PhD

The Co-operatetive University of Kenya


September - December 2024

Contents
1 History of C Programming Language 2
1.1 Origins and Development . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Standardization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Overview of C Language Features and Applications 2


2.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Setting Up the Programming Environment (IDE, Compiler) 3


3.1 Integrated Development Environment (IDE) . . . . . . . . . . . . 3
3.2 Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3 Setting Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4 Writing and Running Your First C Program (Hello World) 5


4.1 Writing Your First Program . . . . . . . . . . . . . . . . . . . . . 5
4.2 Compiling and Running . . . . . . . . . . . . . . . . . . . . . . . 5

1
1 History of C Programming Language
1.1 Origins and Development
• 1969-1973: C programming language was developed by Dennis Ritchie
at AT&T Bell Labs.
• Influence: Derived from the B language, which was influenced by BCPL
(Basic Combined Programming Language).
• Purpose: Initially created for system programming for the Unix operat-
ing system, allowing Unix to be ported to different computers.
• K&R C: The first edition of ”The C Programming Language” by Brian
Kernighan and Dennis Ritchie, published in 1978, became known as K&R
C.

1.2 Standardization
• 1983: ANSI (American National Standards Institute) established a com-
mittee to standardize C.
• 1989: The ANSI C standard, known as ANSI X3.159-1989 or C89.

• 1990: ISO (International Organization for Standardization) adopted it as


ISO/IEC 9899:1990, also known as C90.
• 1999: An updated version known as C99 introduced new features like
inline functions, variable-length arrays, and new data types.

• 2011: C11 standard introduced multi-threading support, improved Uni-


code support, and other enhancements.
• 2018: C18 (or C17) included minor revisions and bug fixes to C11.

2 Overview of C Language Features and Appli-


cations
2.1 Key Features
• Portability: C programs can run on different types of computers with
little or no modification.
• Efficiency: C provides low-level access to memory and system processes,
which allows for highly efficient programs.
• Flexibility: C supports both high-level and low-level programming, mak-
ing it suitable for a variety of applications.

2
• Rich Library: Extensive library of built-in functions.
• Modularity: Supports modular programming with functions, which al-
lows code to be reused.
• Structured Programming: C emphasizes structured programming, al-
lowing developers to write clear, logical code blocks.

2.2 Applications
• System Programming: Operating systems, embedded systems, and
compilers (e.g., Unix, Linux).
• Application Development: Desktop applications, databases, and util-
ities.
• Game Development: High-performance games and graphics engines.

• Embedded Systems: Microcontrollers, IoT devices.


• Network Programming: Network protocols, socket programming.
• Scientific Computing: Numerical analysis, simulations.

3 Setting Up the Programming Environment (IDE,


Compiler)
3.1 Integrated Development Environment (IDE)
• Code::Blocks:
– Free, open-source IDE.
– Features: Code completion, syntax highlighting, debugger, and cus-
tomizable interface.
• Visual Studio Code:

– Free, open-source text editor with extensions for C/C++ develop-


ment.
– Features: Integrated terminal, source control, debugging tools.
• Eclipse:

– Open-source IDE with extensive plugin support.


– Features: Code navigation, refactoring tools, build automation.

3
3.2 Compilers
• GCC (GNU Compiler Collection):
– Standard compiler for Unix-like systems.
– Command-line based, widely used in open-source projects.
• Clang:
– Compiler based on LLVM, known for its performance and modularity.
– Provides detailed error messages and diagnostics.
• Microsoft Visual C++:
– Part of Visual Studio, used for Windows development.
– Features: Integrated with Visual Studio’s debugging and develop-
ment tools.

3.3 Setting Up
• Windows:
– Install Code::Blocks: Download from http://www.codeblocks.org/
downloads and follow the installation instructions.
– Install Visual Studio Code: Download from https://code.visualstudio.
com/, install the C/C++ extension from the marketplace.
– Install MinGW for GCC: Use Instructions in the following link https:
//code.visualstudio.com/docs/cpp/config-mingw, follow the setup
instructions to install GCC.
• MacOS:
– Install Xcode: Available on the Mac App Store, includes Clang com-
piler.
– Install Visual Studio Code: Same as Windows, with C/C++ exten-
sion.
– Install Homebrew for GCC: Use brew install gcc to install GCC
via Homebrew.
• Linux:
– Install GCC: Use package manager (e.g., sudo apt-get install
gcc on Ubuntu).
– Install Code::Blocks: Use package manager (e.g., sudo apt-get install
codeblocks on Ubuntu).
– Install Visual Studio Code: Download the .deb package from https:
//code.visualstudio.com/ and install using sudo dpkg -i <file>.deb.

4
4 Writing and Running Your First C Program
(Hello World)
4.1 Writing Your First Program
Code:
1 # include < stdio .h >
2

3 int main () {
4 printf ( " Hello , ␣ World !\ n " ) ;
5 return 0;
6 }

Explanation:
• #include <stdio.h>: Preprocessor directive to include the standard input-
output library.
• int main(): Main function where the execution starts.
• printf("Hello, World!
n"): Prints ”Hello, World!” to the console.
• return 0: Ends the program, returning 0 to the operating system.

4.2 Compiling and Running


Using GCC (Command Line):
• Open terminal or command prompt.
• Navigate to the directory containing your C file.
• Compile the program using:
1 gcc hello . c -o hello

• Run the compiled program:


1 ./ hello

Using Code::Blocks:
• Open Code::Blocks.
• Create a new project: File -¿ New -¿ Project -¿ Console Application -¿ C.
• Write the program in the main.c file.
• Build and run the program: Build -¿ Build and run.

5
Using Visual Studio Code:
• Open Visual Studio Code.
• Create a new file named hello.c and write the program.
• Open terminal in VS Code.

• Compile using GCC:


1 gcc hello . c -o hello

• Run the program:


1 ./ hello

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy