SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
2.0 INTRODUCTORY CONCEPT
CLO 1, CLO 2
1.Explain various programming problem using
design tools (C2)
2. Apply knowledge of basic concepts of
fundamental programming to solving a given
problem
2.0 INTRODUCTORY CONCEPT
At the end of this chapter, student will be able to :
1. Define a variable and a constant
2. Identify the rules for naming variables and
constant,
3. Declare constants and variables
4. Build constant and variables
5. Explain keywords and operators in
programming
6. Use keywords and operators
2.0 INTRODUCTORY CONCEPT
At the end of this chapter, student will be able
to :
7. Convert formula into C expression
2.1 Constant And Variables(Identifier)
2.1.1 Variable And Constant
Variable
• Refer to the memory location
where the data is stored
• This value keeps changing during
the program execution
Figure 2.1(i) : Representation of Variable in Memory
2.1.1 Constant
• a location in the memory that stores
data that never changes during the
execution of the program
• constant can either be:


A numbers, like 15 or 10.5



A single character, like 'x' or '#„



A group of characters
(string), like “Beautiful
Malaysia”
2.1.2 Rules For Naming Constants And
Variables
• Can be a combination of alphabets
and numbers but must start with an
alphabet
• Comprise maximum of 40 characters
• No commas or blank space is allowed
• No special characters can be used
except underscore (_)
2.1.3 Declare Constants And Variables
• Constant and variable used in a program
must be declared in the beginning
• To specify the variable and constant data
type to the compiler
Declare Constant
const data_type name=value ;
e. g :
const float pie=3.14 ;
const int Days_of_Week=7;
const char Colour=“RED”;
Declare Variable
data_type name ;
e. g :
float mark_1 ;
int Quantity;
char StudentID;
2.1.4 Scope of Constants And
Variables

DIY
2.0 INTRODUCTORY CONCEPT
2.1 Understand Constant And
Variables(Identifier)
2.1.5 Build Constants and variables in
Programmes
Total
Pie
Payment
2.1.6 Identify and Explain Keywords in
C Programmes
Are reserved words for which the
meaning is already defined to the
compiler.
an identifier cannot have the same spelling
and case as a C keyword
Types

Keywords

Data types, modifiers and
storage class specifiers

void, int, char, float, double, signed,
unsigned, long, short, auto, const, extern,
static, volatile, register and typedef

User defined data types and
type related

struct,

Conditional

if, else, switch, case and default

Flow control

for, while, do, break, continue, goto and
return

union, enum and sizeof
2.1.7 Use Keywords In Programmes
#include<stdio.h>
int main()
{
printf("Hello worldn");
return 0;
}
2.1.7 Use Keywords In Programmes
#include<stdio.h>
main()
{
int a;
printf("Enter an integern");
scanf("%d", &a);
printf("Integer that you have
entered is %dn", a);
return 0;
2.1.7 Use Keywords In Programmes
#include<stdio.h>
main()
{
char ch;
printf("Enter a charactern");
scanf("%c",&ch);
if ( ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' ||
ch=='O' || ch == 'u' || ch == 'U')
printf("%c is a vowel.n", ch);
else
printf("%c is not a vowel.n", ch);
return 0;
}
2.0 INTRODUCTORY CONCEPT
2.2 Understand Data Types
Data Types
Data types are used to store various
types of data that is processed by
program. Data type attaches with
variable to determine the number of
bytes to be allocate to variable and
valid operations which can be
performed on that variable
2.2.1 Basic Data Types in C
The C language provides a lot of basic types.
Most of them are
formed from one of
the four basic arithmetic type identifiers
in C (char, int, float and double), and
optional specifiers (signed, unsigned, short,
long). All available basic arithmetic
types are listed below:
Char
Short
Short int
Signed short
Signed short int
Int
Signed int
Long
long int

signed long
signed long int
long long
long long int
signed long long
signed long long int
float
double
2.2.2 Basic Data Types
Numeric
Numeric
Keyword
char
int
short
short int
long
unsigned char
unsigned int
unsigned short
unsigned long
float

double

Variable Type
Character (or string)
integer
Short integer
Short integer
Long integer
Unsigned character
Unsigned integer
Unsigned short integer
Unsigned long integer
Single-precision
floating-point
(accurate to 7 digits)
Double-precision
floating-point
(accurate to 15 digits)

Range
-128 to 127
-32,768 to 32,767
-32,768 to 32,767
-32,768 to 32,767
2,147,483,648 to 2,147,483,647
0 to 255
0 to 65,535
0 to 65,535
0 to 4,294,967,295
+/-3.4E10^38 to +/-3.4E10^38

+/-1.7E10^308 to +/1.7E10^308
Characters
C stores character type internally as an
integer. Each character has 8 bits so we
can have 256 different characters values
(0- 255).Character set is used to map
between an integer value and a
character. The most common character
set is ASCII.
The char type store only one symbol of
data (letter, digit, space, tab and so on).
Relational
Relational operators are used to compare two
operands.
Logical
• Logical operators are used to combine two
simple statements into a compound statement.
• Using logical operators, you can simulate
Boolean algebra in C.
Boolean
Boolean operators define the relationships
between words or groups of words.
True=1
False=0
2.3.2 Operators used in programming
3 types :
a. Mathematic operators
b. Relational operators
c. Logical operators
2.3.3 a.Arithmetic
Operator
+
/
*
%
++
--

Action
Substraction
Addition
Divide
Multiplication
Modulus Division
Increment
Decrement
Operator precedence :
i)bracket ()
ii) *,/,% (left to right)
iii)+,- (left to right)
Example 1
Example 2
b.Relational

Operator
<
<=
>
>=
==
!=

Meaning
Less than
Less than or equal
Greater than
Greater than or equal
Equal
Not equal
Statement
You will pass the exam only
when you get more than 50
in subject 1, subject 2 and
subject3.
To get a medal, you should
either be 1st or
2nd in
the race.
If your sex is not M, you are
girl

C Expression
if ((subject1>=50)&&(subject2>=50)&&(subject3>=50))
printf("PASS") ;

if ((position==1)|| (position==2))
printf("You got medal") ;

if (!(sex =='M') ){
printf("You are girl");
2.3.5 Formula VS Expression
Formula

• Equation or a set of instructions that
solves a certain type of problems in a
prescribed manner.
• In a formula, the same set of inputs
always produces the same output(s).
e.g:
Net Pay = Gross Pay – Deductions
Circle Area = ¶R²
Voltage = Current + Resistant
R = ρ x L/A
Expression
• Expression in C++ are formed by
properly combining operators, variables
and constants.
• We have already seen some examples of
simple arithmetic and logical expression
• As algebra, C++ expression can be
complex.
• Parentheses can be used to force the
order of evaluation. An expression may
also contain spaces for readability.
e.g:
Gross_pay – deductions
(basic_pay + hours * rate) – (socso + premium + loan)

(b * b – 4 * a * c) > 0
(gender = = ‘m’) && (age > 20)
(gender = = ‘m’ || gender = = ‘f’ ) && age >= 21
2.3.6 Convert Formula Into C
Formula

Expression
C Expression

Net Pay = Gross Pay – Deductions NetPay = GrossPay – Deductions

Area = ¶R²

Area = Pie x Radius * Radius

V = IR

V = Current x Resistant

R=L

L
_
A

Resistivity= Rho x(Length/Area)
2.3.7 Operand And Operator

An operation is an action performed on
one or more values either to modify the
value held by one or both of the variables
or to produce a new value by combining
variables. Therefore, an operation is
performed using at least one symbol and
one value. The symbol used in an
operation is called an operator. A variable
or a value involved in an operation is called
an operand.
Operator
Assignment (=)
Arithmetic(+,-…..)
Relational(<,>…)
Logical(&&,||,!)

Area = Pie x Radius * Radius

Variable or
Value

Operand
2.3.8 Expressions In Application

first + second
first – second
first * second
first / second
2.3.8 Expressions In Application

diam/2
PI * r * r
2 * PI * r
2.3.8 Expressions In Application

diam/2
area=PI * r * r
circ = 2 * PI * r
Definition
Rules For Naming
Declaration
Scope

CONSTANTS
AND

Build
Keywords

VARIABLES
Types of Operators
Formula VS Expression

2.
INTRODUCTORY

CONCEPT
Basic Data Types

Convert Formula into C
Expression

OPERATORS
Operand and
Operator

AND
EXPRESSIONS

DATA TYPES

Contenu connexe

Tendances

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C ProgrammingKamal Acharya
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variableseShikshak
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
C++
C++C++
C++k v
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++Ameer Khan
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++Shobi P P
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data typesManisha Keim
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic Manzoor ALam
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in cyash patel
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
 
Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Abou Bakr Ashraf
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Abou Bakr Ashraf
 

Tendances (20)

Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Mesics lecture 3 c – constants and variables
Mesics lecture 3   c – constants and variablesMesics lecture 3   c – constants and variables
Mesics lecture 3 c – constants and variables
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
C Tutorial
C TutorialC Tutorial
C Tutorial
 
Data type in c
Data type in cData type in c
Data type in c
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
C++
C++C++
C++
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
 
Structure and Enum in c#
Structure and Enum in c#Structure and Enum in c#
Structure and Enum in c#
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
C Tokens
C TokensC Tokens
C Tokens
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
Visula C# Programming Lecture 7
Visula C# Programming Lecture 7Visula C# Programming Lecture 7
Visula C# Programming Lecture 7
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 

Similaire à introductory concepts

C programming language
C programming languageC programming language
C programming languageAbin Rimal
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginnersophoeutsen2
 
C prog ppt
C prog pptC prog ppt
C prog pptxinoe
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptxRowank2
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...Rowank2
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language Rowank2
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C ProgrammingMOHAMAD NOH AHMAD
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 FocJAYA
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C languageSachin Verma
 

Similaire à introductory concepts (20)

C programming language
C programming languageC programming language
C programming language
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
C prog ppt
C prog pptC prog ppt
C prog ppt
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
C material
C materialC material
C material
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
 
C intro
C introC intro
C intro
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptx
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Unit 4 Foc
Unit 4 FocUnit 4 Foc
Unit 4 Foc
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
 
Basic of the C language
Basic of the C languageBasic of the C language
Basic of the C language
 

Dernier

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 

Dernier (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 

introductory concepts

  • 1. 2.0 INTRODUCTORY CONCEPT CLO 1, CLO 2 1.Explain various programming problem using design tools (C2) 2. Apply knowledge of basic concepts of fundamental programming to solving a given problem
  • 2. 2.0 INTRODUCTORY CONCEPT At the end of this chapter, student will be able to : 1. Define a variable and a constant 2. Identify the rules for naming variables and constant, 3. Declare constants and variables 4. Build constant and variables 5. Explain keywords and operators in programming 6. Use keywords and operators
  • 3. 2.0 INTRODUCTORY CONCEPT At the end of this chapter, student will be able to : 7. Convert formula into C expression
  • 4. 2.1 Constant And Variables(Identifier) 2.1.1 Variable And Constant Variable • Refer to the memory location where the data is stored • This value keeps changing during the program execution
  • 5. Figure 2.1(i) : Representation of Variable in Memory
  • 6. 2.1.1 Constant • a location in the memory that stores data that never changes during the execution of the program • constant can either be:  A numbers, like 15 or 10.5  A single character, like 'x' or '#„  A group of characters (string), like “Beautiful Malaysia”
  • 7. 2.1.2 Rules For Naming Constants And Variables • Can be a combination of alphabets and numbers but must start with an alphabet • Comprise maximum of 40 characters • No commas or blank space is allowed • No special characters can be used except underscore (_)
  • 8. 2.1.3 Declare Constants And Variables • Constant and variable used in a program must be declared in the beginning • To specify the variable and constant data type to the compiler
  • 9. Declare Constant const data_type name=value ; e. g : const float pie=3.14 ; const int Days_of_Week=7; const char Colour=“RED”;
  • 10. Declare Variable data_type name ; e. g : float mark_1 ; int Quantity; char StudentID;
  • 11. 2.1.4 Scope of Constants And Variables DIY
  • 12. 2.0 INTRODUCTORY CONCEPT 2.1 Understand Constant And Variables(Identifier) 2.1.5 Build Constants and variables in Programmes Total Pie Payment
  • 13. 2.1.6 Identify and Explain Keywords in C Programmes Are reserved words for which the meaning is already defined to the compiler. an identifier cannot have the same spelling and case as a C keyword
  • 14. Types Keywords Data types, modifiers and storage class specifiers void, int, char, float, double, signed, unsigned, long, short, auto, const, extern, static, volatile, register and typedef User defined data types and type related struct, Conditional if, else, switch, case and default Flow control for, while, do, break, continue, goto and return union, enum and sizeof
  • 15. 2.1.7 Use Keywords In Programmes #include<stdio.h> int main() { printf("Hello worldn"); return 0; }
  • 16. 2.1.7 Use Keywords In Programmes #include<stdio.h> main() { int a; printf("Enter an integern"); scanf("%d", &a); printf("Integer that you have entered is %dn", a); return 0;
  • 17. 2.1.7 Use Keywords In Programmes #include<stdio.h> main() { char ch; printf("Enter a charactern"); scanf("%c",&ch); if ( ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U') printf("%c is a vowel.n", ch); else printf("%c is not a vowel.n", ch); return 0; }
  • 18. 2.0 INTRODUCTORY CONCEPT 2.2 Understand Data Types Data Types Data types are used to store various types of data that is processed by program. Data type attaches with variable to determine the number of bytes to be allocate to variable and valid operations which can be performed on that variable
  • 19. 2.2.1 Basic Data Types in C The C language provides a lot of basic types. Most of them are formed from one of the four basic arithmetic type identifiers in C (char, int, float and double), and optional specifiers (signed, unsigned, short, long). All available basic arithmetic types are listed below:
  • 20. Char Short Short int Signed short Signed short int Int Signed int Long long int signed long signed long int long long long long int signed long long signed long long int float double
  • 21. 2.2.2 Basic Data Types Numeric
  • 22. Numeric Keyword char int short short int long unsigned char unsigned int unsigned short unsigned long float double Variable Type Character (or string) integer Short integer Short integer Long integer Unsigned character Unsigned integer Unsigned short integer Unsigned long integer Single-precision floating-point (accurate to 7 digits) Double-precision floating-point (accurate to 15 digits) Range -128 to 127 -32,768 to 32,767 -32,768 to 32,767 -32,768 to 32,767 2,147,483,648 to 2,147,483,647 0 to 255 0 to 65,535 0 to 65,535 0 to 4,294,967,295 +/-3.4E10^38 to +/-3.4E10^38 +/-1.7E10^308 to +/1.7E10^308
  • 23. Characters C stores character type internally as an integer. Each character has 8 bits so we can have 256 different characters values (0- 255).Character set is used to map between an integer value and a character. The most common character set is ASCII. The char type store only one symbol of data (letter, digit, space, tab and so on).
  • 24. Relational Relational operators are used to compare two operands.
  • 25. Logical • Logical operators are used to combine two simple statements into a compound statement. • Using logical operators, you can simulate Boolean algebra in C.
  • 26. Boolean Boolean operators define the relationships between words or groups of words. True=1 False=0
  • 27. 2.3.2 Operators used in programming 3 types : a. Mathematic operators b. Relational operators c. Logical operators
  • 29. Operator precedence : i)bracket () ii) *,/,% (left to right) iii)+,- (left to right)
  • 32. b.Relational Operator < <= > >= == != Meaning Less than Less than or equal Greater than Greater than or equal Equal Not equal
  • 33. Statement You will pass the exam only when you get more than 50 in subject 1, subject 2 and subject3. To get a medal, you should either be 1st or 2nd in the race. If your sex is not M, you are girl C Expression if ((subject1>=50)&&(subject2>=50)&&(subject3>=50)) printf("PASS") ; if ((position==1)|| (position==2)) printf("You got medal") ; if (!(sex =='M') ){ printf("You are girl");
  • 34. 2.3.5 Formula VS Expression Formula • Equation or a set of instructions that solves a certain type of problems in a prescribed manner. • In a formula, the same set of inputs always produces the same output(s).
  • 35. e.g: Net Pay = Gross Pay – Deductions Circle Area = ¶R² Voltage = Current + Resistant R = ρ x L/A
  • 36. Expression • Expression in C++ are formed by properly combining operators, variables and constants. • We have already seen some examples of simple arithmetic and logical expression • As algebra, C++ expression can be complex. • Parentheses can be used to force the order of evaluation. An expression may also contain spaces for readability.
  • 37. e.g: Gross_pay – deductions (basic_pay + hours * rate) – (socso + premium + loan) (b * b – 4 * a * c) > 0 (gender = = ‘m’) && (age > 20) (gender = = ‘m’ || gender = = ‘f’ ) && age >= 21
  • 38. 2.3.6 Convert Formula Into C Formula Expression C Expression Net Pay = Gross Pay – Deductions NetPay = GrossPay – Deductions Area = ¶R² Area = Pie x Radius * Radius V = IR V = Current x Resistant R=L L _ A Resistivity= Rho x(Length/Area)
  • 39. 2.3.7 Operand And Operator An operation is an action performed on one or more values either to modify the value held by one or both of the variables or to produce a new value by combining variables. Therefore, an operation is performed using at least one symbol and one value. The symbol used in an operation is called an operator. A variable or a value involved in an operation is called an operand.
  • 41. 2.3.8 Expressions In Application first + second first – second first * second first / second
  • 42. 2.3.8 Expressions In Application diam/2 PI * r * r 2 * PI * r
  • 43. 2.3.8 Expressions In Application diam/2 area=PI * r * r circ = 2 * PI * r
  • 44. Definition Rules For Naming Declaration Scope CONSTANTS AND Build Keywords VARIABLES Types of Operators Formula VS Expression 2. INTRODUCTORY CONCEPT Basic Data Types Convert Formula into C Expression OPERATORS Operand and Operator AND EXPRESSIONS DATA TYPES