An Introduction to C Programming Language

AlonTashobya 8 views 12 slides Oct 19, 2025
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

C Programming Development Life Cycle and Why is C programing


Slide Content

LECTURE 2: An Introduction to C Programming Language

Why Use C Programming Language? C is a powerful and flexible language. It’s a fundamental popular language preferred by most programmers. C is portable, meaning a C program written in one computer system can be compiled and run on another system. Supports Modular Programming Development Using Functions. Supports Software Reusability.

C Programming Development Life Cycle. (PDLC) Create Source Code: Series of statements or commands that instruct the computer to perform a desired task. Using In- Built Editors: Enter the source code in to the compiler, e.g. gcc linux editor Compile the Source Code. Linking to create an executable file. Complete the development life cycle.

Diagrammatic Representation of the PDLC

The Structure of a C Program 1: #include <stdio.h > // header file 2 : main() // beginning of program body 3 : { //beginning of program body 4 : printf("Hello, World!\n "); //Displays Output 5 : return 0 ; // terminate the program normally, return value 0 to the operating system. 6 : } // symbolizes end of program body

Components of a C Program Header files: #include<stdio.h>, the #include instructs the compiler to add contents of the include file to your program during compilation. m ain(): beginning of program body. Variable definition: A variable is a name assigned to a data storage location. Function Prototype * : {Refer to Functions Later} Program Statements or lines of code : (as above) p rintf: displays information on the screen output

Cont’d … s canf: reads data from keyboard. r eturn: abort program normally and return control to the operating system. c omments: /*……*/ or // b races: enclose the program body symbolizing the beginning and end of program body {…}

Variables & Constants Storing data in C programs we use variables or constants. Variables: A named data storage location in your computers memory e.g. a, cal_num. Not acceptable variables #a, cal num etc. Reserved words (Keywords): should never be used as variables such as the data types, functions. Constants: have defined values e.g. PI = 3.142

C Fundamental Numeric Data Types Data Type Keyword* (C Format !) Bytes Required Range* Character Char 1 -128 to 127 Integer Int 2 - 32768 to 32767 Short integer short int 2 -32768 to 32767 Long integer long int 4 -2,147,483,648 to 2,147,438,647 Unsigned character Unsigned char 1 0 to 255 Unsigned integer Unsigned int 2 0 to 65535 Unsigned short integer Unsigned short int 2 0 to 65535 Unsigned long integer Unsigned long int 4 0 to 4,294,967,295 Single-precision floating-point float 4 1.2E-38 to 3.4E38 1 Double-precision floating-point double 8 2.2E-308 to 1.8E308 2

Variable Declaration i nt a; f loat cal_num; Other Keywords (Read!): enum, typedef, constants, symbolic constants, literal constants with a const keyword Note: #define PI 3.31412 and int a = 22.4

ASSIGNMENT!!! In groups of 10, prepare short presentations slides (5) to demonstrate how we use the following compiler to edit, debug and compile computer programs : BorlandC 4.5 Compiler or Higher Version { 5 Marks } Linux Compiler { 7 Marks } Requirements: {Demo [ Slide # 5 ]: Structure of a Program} Members will be chosen randomly to demonstrate on how these compilers work on behalf of the entire group. O n presenting you must present list of group members. Use Microsoft Slides for Presentation/Demo Purposes. Members from @ group will be selected randomly to represent the rest of the members. Deadline: 6 th October 2013

Readings ! The Fundamental Operators in C Programming C Expressions { Simple and Complex } Statements in C { Simple and Compound } Reserved (Key)Words in C Programming Language Order of Precedence in C complex expressions Define Variables, Declaration of Variables Assigning a value to a Variable How do Input and Output values in the Program? {which functions are used & how?}
Tags