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

Module one

The document outlines a course titled 'Introduction to Computer Programming with C' taught by Charles Masoud at KIUT, covering fundamental programming concepts and the C language. Key topics include data types, operators, control flow, functions, and variable scope. It also details the rules for identifiers and variables, emphasizing the importance of understanding data manipulation in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Module one

The document outlines a course titled 'Introduction to Computer Programming with C' taught by Charles Masoud at KIUT, covering fundamental programming concepts and the C language. Key topics include data types, operators, control flow, functions, and variable scope. It also details the rules for identifiers and variables, emphasizing the importance of understanding data manipulation in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

COURSE TITLE : INTRODUCTION TO

COMPUTER PROGRAMMING WITH C

Lecturer:Charles Masoud
Faculty of Computing, Management and Social
Sciences(FCMSS), KIUT.
COURSE CODE: CS 1201
PHONE:0767999857
:Course Content
• Introduction to programming & Algorithms
• Computer Programming Basics
• Introduction to C Language
• Control Flow Statements
• Introduction to Loops
• Strings and Pointers
• Arrays
• Functions & Recursion
• Structures
• Data Files
2
Operators in C
• C language supports a rich set of built-in operators.
An operator is a symbol that tells the compiler to
perform a certain mathematical or logical
manipulation.
• Operators are used in programs to manipulate data
and variables.

3
• C operators can be classified into following types:
Arithmetic operators
1. Relational operators
2. Logical operators
3. Bitwise operators
4. Assignment operators
5. Conditional operators
4
6. Special operators
Arithmetic operators
• C supports all the basic arithmetic operators. The following
table shows all the basic arithmetic operators.

5
Relational operators
• The following table shows all relation operators
supported by C.

6
Bitwise operators
• Bitwise operators in C language are used to perform
operations directly on the binary representations of
numbers, manipulating individual bits within data types like
integers.
• Unlike arithmetic operators in C that work with whole
values, bitwise operators allow you to control, modify, and
analyze bits independently, making them essential for tasks
in systems programming, low-level data manipulation, and
memory optimization.
7
8
Data types

There are s three classes of data types;


Primary/Simple/Fundamental/Basic data type
Compound/Derived data types
User-defined data types

9
Simple Data Types
• Simple or primitive data types are the fundamental building blocks of
data in programming languages.
• They represent the most basic forms of data and are used to create
variables that store individual pieces of information.
• Types of simple data types:
Integer (int)
Character (char)
Float (float)
Double (double)
Boolean (bool)
10
Integer (int)

• Definition: Represents whole numbers without any


fractional or decimal part.
• Storage: Typically 4 bytes (32 bits) on most systems, but
this can vary.
• Example: int age = 25;

11
Float (float)
• Definition: Represents floating-point numbers or real numbers
that have a fractional part.
• Storage: Typically 4 bytes.
• Range and Precision: Can represent a wide range of values but
with limited precision.
• Example: float salary = 75000.50;

12
Double (double)
• Definition: Similar to float, but with double the
precision and range.
• Storage: Typically 8 bytes.
• Example: double pi = 3.141592653589793;

13
Character (char)
• Definition: Represents a single character.
• Storage: Typically 1 byte.
• Example: char grade = 'A';

14
Compound Data Structures
• Compound data structures are collections of primitive data
types that allow for the storage and organization of multiple
values.
• They provide more complex ways to organize data and can
represent more complex entities

15
Identifiers
• Identifiers refer to the names of variables, functions ad
arrays. These are user defined names and consists of a
sequence of letters and digits, with a letter as a first
character.

16
Rules for Identifiers
• First letter must be an alphabet (or underscore).
• Must consist of only letters, digits or underscore.
• Uppercase and lowercase are considered to be distinct.
• Cannot be a Keyword.
• Must not contain white spaces.

17
Variables
• A variable is a storage location identified by a name
(identifier) that holds a value which can be changed during
program execution.
• Declaring a variable involves specifying its type and name.
Example: int score;
• Initializing a variable assigns it an initial value.
Example: int score = 100;

18
Rules for variables
• First letter must be an alphabet (or underscore).
• Must consist of only letters, digits or underscore.
• Uppercase and lowercase are considered to be distinct.
• Cannot be a Keyword.
• Must not contain white spaces.

19
Variable Scope
• Local Scope: Variables declared inside a function or block
are accessible only within that function or block.
• Global Scope: Variables declared outside all functions are
accessible throughout the program.
• Function Scope: Variables declared within a function are
accessible only within that function.
• Block Scope: Variables declared inside a block (e.g., inside
{}) are accessible only within that block.
20

You might also like