SlideShare a Scribd company logo
PROGRAM CONTROL
PROGRAM CONTROL STRUCTURE
• Program control structure controls the flow of
execution of program statement.
• C++ provides structures that will allow an
instruction or a block of instruction to be
executed, repeated and skipped.
• There are three control structure:
 sequential structure
 selection structure
 repetition structure
Sequence structure
• The sequence structure has one entry point
and one exit point.
• No choice are made and no repetition.
• Statement are executed in sequence, one
after another without leaving out any single
statement.
flowchart
Statement 1
Statement 2
Statement n
Example of sequential statement
#include<iostream>
using namespace std;
int main()
{
float payrate=8.5;
float hourWorked=25.0;
float wages;
wages= hourWorked * payrate;
cout<<“n Wages = RM:”<<wages<<endl;
return 0;
}
Output:
Wages = RM:212.5
Example of sequential statement
include<iostream>
using namespace std;
int main()
{
int num1,num2;
float total;
cout<<“NUMBER 1:”;
cin>>num1;
cout<<“NUMBER 2:”;
cin>>num2;
total=num1+num2;
cout<<“TOTAL OF TWO NUMBERS IS:”<<total<<endl;
return 0;
}
Output:
NUMBER 1:10
NUMBER 2:5
TOTAL OF TWO NUMBERS IS:15
Selection structure
• The selection structure is used to allow
choices to be made.
• This program executes particular statements
depending on some condition(s).
• C++ uses if..else, nested if and switch..case
statement for making decision.
Selection statement
If…else
• A selection of control structure is used to select
between two or more options.
• Used to make decision based on condition.
• else statement will never exist in a program
without if statement.
• If tested condition is TRUE, the entire block of
statements following the if is performed.
• If the tested condition is FALSE, the entire block
of statement following the else is performed
flowchart
false true
condition
Statement 2 Statement 1
syntax
if(condition)
{
true statement
}
else
{
false statement
}
Example of if..else statement
#include<iostream>
using namespace std;
int main()
{
int age;
cout<<“n Key in your age:”<<age;
cin>>age;
if(age>21)
{
cout<<“Qualifiied to have driving license”;
}
else
{
cout<<“Not qualified to have driving license”;
}
return 0;
}
Output:
Key in your age:18
Not qualified to have driving license
Output:
Key in your age:25
Qualifiied to have driving license
Output:
Key in your age:21
Not qualified to have driving license
Nested if..else
condition1
condition2
condition3
Statement A
Statement C
Statement D
true
false
true
false
true
Statement B
false
Nested if..else
If(condition 1)
{
If(condition 2)
{
If(condition 3)
{
Statement A
}
else
{
Statement B
}
}
else
{
Statement c
}
}
else
{
Statement D
}
• In this nested form, condition 1 is evaluated. If it
is zero, statement D is executed and the entire
nested if statement is terminated.
• In not, control goes to the second if and condition
2 is evaluated. If it is zero, statement C is
executed.
• If not, control goes to the third if and condition 3
is evaluated. If it is zero, statement B is executed .
• If not , statement A executed.
Example of statement#include<iostream>
using namespace std;
int main()
{
float cgpa,salary;
int year;
cout<<“n YEAR:”;
cin>>year;
cout<<“n CGPA:”;
cin>>cgpa;
cout<<“n SALARY:”;
cin>>salary;
if(year>1)
{
if(cgpa>=3.00)
{
if(salary<=500)
{
cout<<“Your application is under consideration”;
}
else
{
cout<<“Not success because salary is more than RM500.00“;
}
}
else
{
cout<<“ Not success because cgpa is less than 3.00”;
}
}
else
{
cout<<“ Not success because yeaa of study is less than 1”;
}
return 0;
Output:
YEAR:2
CGPA:3.5
SALARY:250
Your application is under consideration
Nested if..else
condition1
condition2
condition3
Statement D
Statement B
Statement A
false
true
false
true
false
Statement C
true
Nested if..else
if(condition 1)
{
Statement A
}
else if(condition 2)
{
Statemnet B
}
else if(condition 3)
{
Statement C
}
else
{
Statement D
}
Example of if..else statement#include<iostream>
using namespace std;
int main()
{
float cgpa;
cout<<“n CGPA:”;
cin>>cgpa;
if(cgpa < 0.00 || cgpa > 4.00)
{
cout<<“Invalid data”;
{
else if(cgpa > = 3.5 && cgpa < = 4.00)
{
cout<<“Dean List”;
}
else if(cgpa > 2.00 && cgpa < 3.50.00)
{
cout<<“Pass”;
}
else if(cgpa > = 1.80 && cgpa < 2.00)
{
cout<<“ Conditional Pass;;
}
else
{
cout<<“ Fail”;
}
return 0;
}
Output:
CGPA:2.5
Pass
Usage of Logical Operator
Symbol
(pseudocode)
Symbol
(c++ language)
Example Result Description
AND && (1>3)&&(10<20) FALSE Both sides of
the condition
must be true.
OR || (1>3)&&(10<20) TRUE Either one of
the condition
must be true.
NOT ! !(10<20) FALSE Change the
operation
either from
true to false or
vise versa.
Example using of AND operator
● If condition ( num1< num2) is true AND condition ( num1 > num3) is true
then print “First number is the largest number” will be displayed.
● If one of the condition is not true then print “First number is the largest
number” will not be displayed.
If ((num1 > num2 ) && ( num1 > num3 ))
cout<<“First number is the largest number”;
Example usage of OR operator:
● if the sales are more than 5000 or working hours
are more than 81, bonus RM500 will be given. If
either condition is not fulfilled, still the amount of
RM500 will be given as bonus.
● If both condition are false, then bonus will not be
given.
If ( ( sales > 5000 ) || (hourseworked > 81 ))
Bonus = 500;
else
Switch case
• The switch..case structure consists of a series of case label
and optional default case which can be included for option
that is not listed in the case label.
• Switch which is followed by variable name in parentheses
called controlling expression.
• The break keyword must be included at the end of each
case statement.
• The break statement causes program control to proceed
with the first statement after the switch structure.
• Without break statement, all command for that case and
next case label will be executed.
• Default is an option that will only be executed if suitable
case cannot be found.
Flowchart
Case 1
Case n
default
Statement for value=1 break
break
Statement for value=1
syntax
Switch(expression)
{
case value 1:
statement if expression =value 1
break;
case value n:
statement if expression =value n
break;
default:
statement if none of the expression is matched
}
Example of program
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<“n Enter a number:”;
cin>>num;
switch(num)
{
case 1:
cout<<“Welcome”;
break;
case 2:
cout<<“Bye”;
break;
default:
cout<<“Wrong Number”;
}
return 0;
Output:
Enter a number:1
Welcome
Example of program without break
statement
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<“n Enter a number:”;
cin>>num;
switch(num)
{
case 1:
cout<<“Welcome”;
case 2:
cout<<“Bye”;
default:
cout<<“Wrong Number”;
}
return 0;
Output:
Enter a number:1
WelcomeByeWrong Number
Example of program
#include<iostream>
using namespace std;
int main()
{
char grade;
cout<<“n Enter a grade (A-D):”;
cin>>grade;
switch(grade)
{
case ‘A’:
cout<<“Minimun marks is 80”;
break;
case ‘B’:
cout<<“Minimun marks is 60”;
break;
case ‘C’:
cout<<“Minimun marks is 40”;
break;
case ‘D’:
cout<<“Minimun marks is 25”;
break;
default:
cout<<“Mark between 0-24”;
}
return 0;
}
Output:
Enter a grade (A-D):C
Minimun mark is 40
• A,B,C, and D are the possible values that can be assigned to the
variable grade.
• In each case of constant, A to D a statement or sequence of
statement would be executed.
• You would have noticed that every line has statement under it
called break.
• The break is the only thing that stop a case statement from
continuing all the way down through each case label under it.
• In fact if you do not put break in, the program will keep going down
in the case statement. Into other case labels, until it reaches the
end of break.
• However the default part is the codes that would be executed if
there were no matching case of constant’s value.
Rules for Switch statement
• The value of case statement must be an integer or a
character constant.
• Case statement arrangement is not important.
• Default can exist earlier ( but compiler will place it at
the end)
• Can’t use condition or limit.
• Why switch is the best way to write a program:
 easy to read
 It is a more spesific statement to implement multiple
alternative decisions.
 It is used to make a decision between many alternative.
Comparison of Nested if statement
and switch..case statement
Nested if statement switch.. case statement
#include<iostream>
using namespace std;
int main()
{
int code;
cout<<“Enter code (1,2 or 3)”;
cin>>code;
if(code==1)
cout<<“Your favourite flavor is vanila”;
else if(code==2)
cout<<“Your favourite flavor is chocolate”;
else if(code==3)
cout<<“Your favourite flavor is strawbery”
else
cout<<“please choose code 1,2 or 3 only”;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int code;
cout<<“Enter code (1,2 or 3)”;
cin>>code;
switch(code)
{
case1:
cout<<“Your favourite flavor is vanila”;
break;
case2:
cout<<“Your favourite flavor is chocolate”;
break;
case 3:
cout<<“Your favourite flavor is strawbery”;
default:
cout<<“please choose code 1,2 or 3 only”;
}
return 0;
}
exercise
1. If the payment RM5,000 to RM10,000, display a message that the
customer will be given a free ticket to Langkawi. Otherwise, display a
message that the customer will only be given a free lunch at Quality
Hotel. Translate the statement above to program segment.
2. You are given the following requirement:
a. Your program is able to read the amount of sales for a sale executive.
b. If the sale is more than RM10,000 then the commission will be 5% of the
sale. Otherwise, the commission is only 3% of the sales.
c. Your program is able to calculate the amount of commission by multiply the
percentage of commission with sale.
d. Your program is able to display the amount of commission to the sale
executive.
3. Write a c++ program to find a maximum value of three integers which are
a, b and c.
exercise
4. You’re given the following requirements:
a. Your program is able to read the item code from the keyboard
b. The item code determines the price for each item in the shop. The following table shows
the prices and charges of 7 items in the shop.
c. If the item code is not matched, an error message is dispayed as follows:
“Error, this item code is not in the list.”
d. For each selected item, the charge is calculated by multiplying the item price and charge rate.
e. Then the payment is a summation of item price and charge. Your program is to display this
payment.
Item Code Price (RM) Charge(%)
A 54.00 5
B 65.00 5
C 82.00 5
D 103.00 7
E 150.00 7
F 245.00 10
H 250.00 10
exercise
4. NASA Consultant Co Ltd wants to develop a program that can help the consultant
to give advice regarding the home loan. The program receives two inputs from the
consultant, which are the amount of House Cost in Ringgit Malaysia and years of
term applied. Based on these two inputs, the program should be able to calculate
the monthly repayment. The table for the interest calculation is provided as follows:
The formulae for the monthly repayment calculation are as follows:
Interest (RM) = Interest (%) x House cost (RM)
House cost with Interest = House Cost (RM) + Interest (RM)
Monthly Repayment = House Cost with Interest / ( Year of Term Applied x 12)
Year of Term Applied Interest (%)
More than or equal to 25 years 7.5
More than or equal to 20 years 6.5
More than or equal to 15 years 5.5
More than or equal to 10 years 4.5
Less than 10 years 4.0
Answer for question 1
(if else)
#include<iostream>
using namespace std;
int main()
{
float payment;
cout<<"Please enter your payment:RM";
cin>>payment;
if(payment>=5000&&payment<=10000)
{
cout<<"Free air ticket to Langkawi";
}
else
{
cout<<"Free lunch at Quality Hotel";
}
return 0;
Answer for question 1
(nested if)#include<iostream>
using namespace std;
int main()
{
float payment;
cout<<"Please enter your payment:RM";
cin>>payment;
if(payment>=5000)
{
if(payment<=10000)
cout<<"Free air ticket to Langkawi";
else
cout<<"Free lunch at Quality Hotel";
}
else
cout<<"Free lunch at Quality Hotel";
return 0;
}
Answer for question 1
if and if else#include<iostream>
using namespace std;
int main()
{
float payment;
cout<<"Please enter your payment:RM";
cin>>payment;
{
if(payment>10000)
{
cout<<"Free lunch at Quality Hotel";
cout<<"ccc";
}
}
{
if(payment>=5000)
{
cout<<"Free air ticket to Langkawi";
cout<<"hiii";
}
else
{
cout<<"Free lunch at Quality Hotel";
cout<<"bye";
}
}
return 0;
}
Answer for question 2
#include<iostream>
using namespace std;
int main()
{
float sale,commission,amount_commission;
cout<<"Please enter your sale:RM";
cin>>sale;
if(sale>10000)
{
commission=0.05;
}
else
{
commission=0.03;
}
amount_commission=sale*commission;
cout<<"Your amount of commission is:RM"<<amount_commission;
return 0;
}
Answer for question 2
#include<iostream>
using namespace std;
int main()
{
float sale,commission,amount_commission;
cout<<"Please enter your sale:RM";
cin>>sale;
if(sale>10000)
{
commission=0.05;
amount_commission=sale*commission;
cout<<"Your amount of commission is:RM"<<amount_commission;
}
else
{
commission=0.03;
amount_commission=sale*commission;
cout<<"Your amount of commission is:RM"<<amount_commission;
}
return 0;
}
Answer question 5
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"ENTER FIRST NUMBER:";
cin>>a;
cout<<"ENTER SECOND NUMBER:";
cin>>b;
cout<<"ENTER THIRD NUMBER:";
cin>>c;
cout<<"n*****************************n";
if(a>b&&a>c)
{
cout<<"MAXIMUM VALUE IS:"<<a;
}
else if(b>a&&b>c)
{
cout<<"MAXIMUM VALUE IS:"<<b;
}
else
{
cout<<"MAXIMUM VALUE IS:"<<c;
}
return 0;
}
Answer for question 6
#include<iostream>
using namespace std;
int main()
{
char code;
float price,charge_rate,charge,payment;
cout<<"ITEM CODE:";
cin>>code;
switch(code)
{
case 'A':price=54.00;
charge_rate=0.05;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'B':price=65.00;
charge_rate=0.05;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'C':price=82.00;
charge_rate=0.05;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'D':price=103.00;
charge_rate=0.07;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'E':price=150.00;
charge_rate=0.07;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'F':price=245.00;
charge_rate=0.1;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
case 'H':price=250.00;
charge_rate=0.1;
charge=price*charge_rate;
payment=price+charge;
cout<<"Your payment is:RM"<<payment;
break;
default:
cout<<"Error, this item code is not in the listn";
}
return 0;
}
Answer for question 7
#include<iostream>
Using namespace.std;
int main()
{
float House_cost,monthly_repayment,interest,interest_pay,House_cost_ineterest;
int year;
cout<<"HOUSE COST IN RM:";
cin>>House_cost;
cout<<"YEAR OF TERM APPLIED:";
cin>>year;
if(year>=25)
{
interest=0.75;
}
else if(year>=20&&year<25)
{
interest=0.65;
}
else if(year>=15&&year<20)
{
interest=0.55;
}
else if(year>=10&&year<15)
{
interest=0.45;
}
else
{
interest=0.40;
}
interest_pay=interest*House_cost;
House_cost_ineterest=House_cost+interest_pay;
monthly_repayment=House_cost_ineterest/(year*12);
cout<<"YOUR REPAYMENT A MONTH IS:RM"<<monthly_repayment;
return 0;
}
Repetition structure
• Why repetition is needed??
• Suppose we want to add five numbers to find their
average.
• From what we have learned so far, we could proceed as
follows.
cin>>num1>>num2>>num3>>num4>>num5;
sum= num1>+num2+num3+num4+num5;
average=sum/5;
• How about we want to add 100 or 1000 numbers ??
• Therefore, repetition structure offers a better way of
performing those task.
count=0;
while(count<100)
{
cin>>num;
sum=sum+num;
count=count+1;
}
average=sum/count;
REPETITION STRUCTURE
• A programming control structure that allows a
series of instructions to be executed more
than once.
• The similar statement is repeated several
times until the condition are fulfilled.
• There are three types of loop:
 for
 while
do..while
Flowchart of for statement
expression statementt
False
For statement
• General form of for structure:
for(initialize;condition;counter)
Statement block;
• The initialize part is used to initialize any variables that may need to
be initialized. This part is performed just once at the start of the
loop.
• The condition part determines wether the loop execution should
continue.
• If the value of expression is TRUE (non zero), the statement block
will be executed otherwise the loop will be terminated.
• The counter part typically increments or decrements the loop
index.
• This performed every time through the loop iteration.
• This part is used to increment any variable that may need to be
incremented.
Example of program
#include<iostream>
using namespace std;
int main()
{
int num, i,sum;
sum=0;
for(i=0;i<5;i++)
{
cout<<“Enter number:”;
cin>>num;
sum=sum+num;
}
cout<<“Total of numbers are:”<<sum;
return 0;
}
Flowchart of While statement
statementt
True
False
condition
While statement
• General form:
while (expression)
statement block;
• The first expression evaluated,
• If it is True the statement block is executed
• If it False, the statement block is skipped
• A while structure allow the program to repeat a set of statement as long as the
starting condition remains true. “True” is used in the boolean sense snd so the
condition for loop to continue must evaluate to true or false.
• The program evaluates the condition if it true then the statement inside the braces
are executed.
• The condition is evaluated again.This will continue untill the condition is false and
the program jumps to the next line after the body of the structure.
• If only one statement is used in the while loop then the braces are not required.
Example of program
#include<iostream>
using namespace std;
int main()
{
int num, i,sum;
i=0;
sum=0;
while(i<5)
{
cout<<“Enter number:”;
cin>>num;
sum=sum+num;
i++;
}
cout<<“Total of numbers are:”<<sum;
return 0;
}
Output:
Enter number:10
Enter number:2
Enter number:12
Enter number:4
Enter number:2
Total of numbers are:30
Flowchart of do…while statement
statementt
True
False
do....while statement
• General form:
do
{
statement block;
}
while(expression);
• The do part contains the body and is executed as long as
the while condition remains true.
• The difference between these two while structure are while
loop the condition is evaluated first and if it immediately
false, the condition is tested and so guaranteed to be
executed at least once.
Example of program
#include<iostream>
using namespace std;
int main()
{
int num, i,sum;
i=0;
sum=0;
do
{
cout<<“Enter number:”;
cin>>num;
sum=sum+num;
i++;
} while(i<5);
cout<<“Total of numbers are:”<<sum;
return 0;
}
Output:
Enter number:5
Enter number:8
Enter number:12
Enter number:3
Enter number:10
Total of numbers are:38
continue and break statement
• Two commands that can be included in
looping processes are continue and break.
• When included continue statement in the
body of the loop causes the program to return
immediately to the start of the loop and
ignore any remaining part of the body.
• The break statement causes the program to
immediately exit from the loop and resume at
the next of the progarm.
Example of program
(continue)
#include<iostream>
using namespace std;
int main()
{
int num, i,sum;
i=0;
sum=0;
while(i<5)
{
i++;
if(i==3)
continue;
cout<<"Enter number "<<i<<":";
cin>>num;
sum=sum+num;
}
cout<<“Total of numbers are:”<<sum;
return 0;
}
Output:
Enter number 1:10
Enter number 2: 5
Enter number 4:12
Enter number 5:3
Total of numbers are:30
Example of program
(break)
#include<iostream>
using namespace std;
int main()
{
int num, i,sum;
i=0;
sum=0;
while(i<5)
{
cout<<“Enter number”;
cin>>num;
sum=sum+num;
i++;
if(i==3)
break;
}
cout<<“Total of numbers are:”<<sum;
return 0;
}
Output:
Enter number:5
Enter number:20
Enter number:10
Total of numbers are:35
Difference between the loops
structure
for while do..while
#include<iostream>
using namespace std;
int main()
{
for(i=0;i<3;i++)
{
cout<<“welcome!”;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
i=0;
while(i<3)
{
cout<<“welcome!”;
i++;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
i=0;
do
{
cout<<“welcome!”;
i++;
} while(i<3);
return 0;
}

More Related Content

What's hot

Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysiaBab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
Are Matt
 
Kata tunggal bahasa
Kata tunggal bahasa Kata tunggal bahasa
Kata tunggal bahasa
Kaizen Kohana
 
Beriman kepada qada’ dan qadar
Beriman kepada qada’ dan qadarBeriman kepada qada’ dan qadar
Beriman kepada qada’ dan qadarAbu eL IQram
 
matlamat penciptaan manusia. CTU asasi sains
matlamat penciptaan manusia. CTU asasi sainsmatlamat penciptaan manusia. CTU asasi sains
matlamat penciptaan manusia. CTU asasi sains
Izzah Aqilah
 
Penghayatan etika dan peradaban ( mpu21032 )
Penghayatan etika dan peradaban  ( mpu21032 )Penghayatan etika dan peradaban  ( mpu21032 )
Penghayatan etika dan peradaban ( mpu21032 )
NurAyuni31
 
MALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
MALAYSIA : KESEPADUAN DAN KEPELBAGAIANMALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
MALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
wan izzati
 
Al adl (maha adil)
Al adl (maha adil)Al adl (maha adil)
Al adl (maha adil)
Khairul Anwar
 
Pembinaan negara bangsa
Pembinaan negara bangsaPembinaan negara bangsa
Pembinaan negara bangsa
Nurfarah Aqilah
 
Pilihanraya di Malaysia
Pilihanraya di MalaysiaPilihanraya di Malaysia
Pilihanraya di Malaysia
Muhammad Haniff
 
Falsafah Idealisme dan pengenalan
Falsafah Idealisme dan pengenalanFalsafah Idealisme dan pengenalan
Falsafah Idealisme dan pengenalanSiti Zulaikha
 
nilai & etika
nilai &  etikanilai &  etika
nilai & etika
@f!Q@H @F!N@
 
Hindari khurafat tahun 6.pptx
Hindari khurafat tahun 6.pptxHindari khurafat tahun 6.pptx
Hindari khurafat tahun 6.pptx
NadirahSalim
 
Kebebasan Bersuara, Berhimpun dan Berpersatuan
Kebebasan Bersuara, Berhimpun dan BerpersatuanKebebasan Bersuara, Berhimpun dan Berpersatuan
Kebebasan Bersuara, Berhimpun dan Berpersatuan
surrenderyourthrone
 
perkahwinan dalam islam
perkahwinan dalam islamperkahwinan dalam islam
perkahwinan dalam islam
Nur Hikmah
 
Topik 4 pemantapan kesepaduan nasional
Topik 4 pemantapan kesepaduan nasionalTopik 4 pemantapan kesepaduan nasional
Topik 4 pemantapan kesepaduan nasional
SharifahNurAbu
 
Usuluddin - Hedonisme
Usuluddin - HedonismeUsuluddin - Hedonisme
Usuluddin - Hedonisme
Aimi Junedi
 
Tajuk 2 Falsafah dalam Kehidupan
Tajuk 2 Falsafah dalam KehidupanTajuk 2 Falsafah dalam Kehidupan
Tajuk 2 Falsafah dalam Kehidupan
Mahyuddin Khalid
 
Syariah poligami
Syariah poligamiSyariah poligami
Syariah poligami
Faizah Yahya
 

What's hot (20)

Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysiaBab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
Bab 5 permuafakatan politik dalam konteks hubungan etnik di malaysia
 
Kata tunggal bahasa
Kata tunggal bahasa Kata tunggal bahasa
Kata tunggal bahasa
 
Beriman kepada qada’ dan qadar
Beriman kepada qada’ dan qadarBeriman kepada qada’ dan qadar
Beriman kepada qada’ dan qadar
 
matlamat penciptaan manusia. CTU asasi sains
matlamat penciptaan manusia. CTU asasi sainsmatlamat penciptaan manusia. CTU asasi sains
matlamat penciptaan manusia. CTU asasi sains
 
Penghayatan etika dan peradaban ( mpu21032 )
Penghayatan etika dan peradaban  ( mpu21032 )Penghayatan etika dan peradaban  ( mpu21032 )
Penghayatan etika dan peradaban ( mpu21032 )
 
Konsep ilmu
Konsep ilmuKonsep ilmu
Konsep ilmu
 
MALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
MALAYSIA : KESEPADUAN DAN KEPELBAGAIANMALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
MALAYSIA : KESEPADUAN DAN KEPELBAGAIAN
 
Al adl (maha adil)
Al adl (maha adil)Al adl (maha adil)
Al adl (maha adil)
 
Pembinaan negara bangsa
Pembinaan negara bangsaPembinaan negara bangsa
Pembinaan negara bangsa
 
Pilihanraya di Malaysia
Pilihanraya di MalaysiaPilihanraya di Malaysia
Pilihanraya di Malaysia
 
Falsafah Idealisme dan pengenalan
Falsafah Idealisme dan pengenalanFalsafah Idealisme dan pengenalan
Falsafah Idealisme dan pengenalan
 
nilai & etika
nilai &  etikanilai &  etika
nilai & etika
 
Hindari khurafat tahun 6.pptx
Hindari khurafat tahun 6.pptxHindari khurafat tahun 6.pptx
Hindari khurafat tahun 6.pptx
 
Kebebasan Bersuara, Berhimpun dan Berpersatuan
Kebebasan Bersuara, Berhimpun dan BerpersatuanKebebasan Bersuara, Berhimpun dan Berpersatuan
Kebebasan Bersuara, Berhimpun dan Berpersatuan
 
Apa itu search engine
Apa itu search engineApa itu search engine
Apa itu search engine
 
perkahwinan dalam islam
perkahwinan dalam islamperkahwinan dalam islam
perkahwinan dalam islam
 
Topik 4 pemantapan kesepaduan nasional
Topik 4 pemantapan kesepaduan nasionalTopik 4 pemantapan kesepaduan nasional
Topik 4 pemantapan kesepaduan nasional
 
Usuluddin - Hedonisme
Usuluddin - HedonismeUsuluddin - Hedonisme
Usuluddin - Hedonisme
 
Tajuk 2 Falsafah dalam Kehidupan
Tajuk 2 Falsafah dalam KehidupanTajuk 2 Falsafah dalam Kehidupan
Tajuk 2 Falsafah dalam Kehidupan
 
Syariah poligami
Syariah poligamiSyariah poligami
Syariah poligami
 

Similar to POLITEKNIK MALAYSIA

Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
sana shaikh
 
Lec16.pptx problem specifications computer
Lec16.pptx problem specifications computerLec16.pptx problem specifications computer
Lec16.pptx problem specifications computer
samiullahamjad06
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
khaledahmed316
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
Haard Shah
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3 rohassanie
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
Komal Kotak
 
Statement
StatementStatement
Statement
Ahmad Kamal
 
Cs1123 5 selection_if
Cs1123 5 selection_ifCs1123 5 selection_if
Cs1123 5 selection_ifTAlha MAlik
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
Neeru Mittal
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
Likhil181
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
Chap 4 c++
Chap 4 c++Chap 4 c++
C++
C++C++
Object Oriented Design and Programming Unit-04
Object Oriented Design and Programming Unit-04Object Oriented Design and Programming Unit-04
Object Oriented Design and Programming Unit-04
sivakumarmcs
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
msharshitha03s
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
Vikram Nandini
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
Chandrakant Divate
 

Similar to POLITEKNIK MALAYSIA (20)

Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Lec16.pptx problem specifications computer
Lec16.pptx problem specifications computerLec16.pptx problem specifications computer
Lec16.pptx problem specifications computer
 
lesson 2.pptx
lesson 2.pptxlesson 2.pptx
lesson 2.pptx
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Statement
StatementStatement
Statement
 
Cs1123 5 selection_if
Cs1123 5 selection_ifCs1123 5 selection_if
Cs1123 5 selection_if
 
Introduction to Selection control structures in C++
Introduction to Selection control structures in C++ Introduction to Selection control structures in C++
Introduction to Selection control structures in C++
 
Condition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptxCondition Stmt n Looping stmt.pptx
Condition Stmt n Looping stmt.pptx
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Chap 4 c++
Chap 4 c++Chap 4 c++
Chap 4 c++
 
C++
C++C++
C++
 
Elements of programming
Elements of programmingElements of programming
Elements of programming
 
Object Oriented Design and Programming Unit-04
Object Oriented Design and Programming Unit-04Object Oriented Design and Programming Unit-04
Object Oriented Design and Programming Unit-04
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN CINPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
INPUT AND OUTPUT STATEMENTS IN PROGRAMMING IN C
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 

More from Aiman Hud

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 

More from Aiman Hud (20)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 

Recently uploaded

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 

Recently uploaded (20)

Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 

POLITEKNIK MALAYSIA

  • 2. PROGRAM CONTROL STRUCTURE • Program control structure controls the flow of execution of program statement. • C++ provides structures that will allow an instruction or a block of instruction to be executed, repeated and skipped. • There are three control structure:  sequential structure  selection structure  repetition structure
  • 3. Sequence structure • The sequence structure has one entry point and one exit point. • No choice are made and no repetition. • Statement are executed in sequence, one after another without leaving out any single statement.
  • 5. Example of sequential statement #include<iostream> using namespace std; int main() { float payrate=8.5; float hourWorked=25.0; float wages; wages= hourWorked * payrate; cout<<“n Wages = RM:”<<wages<<endl; return 0; } Output: Wages = RM:212.5
  • 6. Example of sequential statement include<iostream> using namespace std; int main() { int num1,num2; float total; cout<<“NUMBER 1:”; cin>>num1; cout<<“NUMBER 2:”; cin>>num2; total=num1+num2; cout<<“TOTAL OF TWO NUMBERS IS:”<<total<<endl; return 0; } Output: NUMBER 1:10 NUMBER 2:5 TOTAL OF TWO NUMBERS IS:15
  • 7. Selection structure • The selection structure is used to allow choices to be made. • This program executes particular statements depending on some condition(s). • C++ uses if..else, nested if and switch..case statement for making decision.
  • 8. Selection statement If…else • A selection of control structure is used to select between two or more options. • Used to make decision based on condition. • else statement will never exist in a program without if statement. • If tested condition is TRUE, the entire block of statements following the if is performed. • If the tested condition is FALSE, the entire block of statement following the else is performed
  • 11. Example of if..else statement #include<iostream> using namespace std; int main() { int age; cout<<“n Key in your age:”<<age; cin>>age; if(age>21) { cout<<“Qualifiied to have driving license”; } else { cout<<“Not qualified to have driving license”; } return 0; } Output: Key in your age:18 Not qualified to have driving license Output: Key in your age:25 Qualifiied to have driving license Output: Key in your age:21 Not qualified to have driving license
  • 12. Nested if..else condition1 condition2 condition3 Statement A Statement C Statement D true false true false true Statement B false
  • 13. Nested if..else If(condition 1) { If(condition 2) { If(condition 3) { Statement A } else { Statement B } } else { Statement c } } else { Statement D }
  • 14. • In this nested form, condition 1 is evaluated. If it is zero, statement D is executed and the entire nested if statement is terminated. • In not, control goes to the second if and condition 2 is evaluated. If it is zero, statement C is executed. • If not, control goes to the third if and condition 3 is evaluated. If it is zero, statement B is executed . • If not , statement A executed.
  • 15. Example of statement#include<iostream> using namespace std; int main() { float cgpa,salary; int year; cout<<“n YEAR:”; cin>>year; cout<<“n CGPA:”; cin>>cgpa; cout<<“n SALARY:”; cin>>salary; if(year>1) { if(cgpa>=3.00) { if(salary<=500) { cout<<“Your application is under consideration”; } else { cout<<“Not success because salary is more than RM500.00“; } } else { cout<<“ Not success because cgpa is less than 3.00”; } } else { cout<<“ Not success because yeaa of study is less than 1”; } return 0; Output: YEAR:2 CGPA:3.5 SALARY:250 Your application is under consideration
  • 16. Nested if..else condition1 condition2 condition3 Statement D Statement B Statement A false true false true false Statement C true
  • 17. Nested if..else if(condition 1) { Statement A } else if(condition 2) { Statemnet B } else if(condition 3) { Statement C } else { Statement D }
  • 18. Example of if..else statement#include<iostream> using namespace std; int main() { float cgpa; cout<<“n CGPA:”; cin>>cgpa; if(cgpa < 0.00 || cgpa > 4.00) { cout<<“Invalid data”; { else if(cgpa > = 3.5 && cgpa < = 4.00) { cout<<“Dean List”; } else if(cgpa > 2.00 && cgpa < 3.50.00) { cout<<“Pass”; } else if(cgpa > = 1.80 && cgpa < 2.00) { cout<<“ Conditional Pass;; } else { cout<<“ Fail”; } return 0; } Output: CGPA:2.5 Pass
  • 19. Usage of Logical Operator Symbol (pseudocode) Symbol (c++ language) Example Result Description AND && (1>3)&&(10<20) FALSE Both sides of the condition must be true. OR || (1>3)&&(10<20) TRUE Either one of the condition must be true. NOT ! !(10<20) FALSE Change the operation either from true to false or vise versa.
  • 20. Example using of AND operator ● If condition ( num1< num2) is true AND condition ( num1 > num3) is true then print “First number is the largest number” will be displayed. ● If one of the condition is not true then print “First number is the largest number” will not be displayed. If ((num1 > num2 ) && ( num1 > num3 )) cout<<“First number is the largest number”;
  • 21. Example usage of OR operator: ● if the sales are more than 5000 or working hours are more than 81, bonus RM500 will be given. If either condition is not fulfilled, still the amount of RM500 will be given as bonus. ● If both condition are false, then bonus will not be given. If ( ( sales > 5000 ) || (hourseworked > 81 )) Bonus = 500; else
  • 22. Switch case • The switch..case structure consists of a series of case label and optional default case which can be included for option that is not listed in the case label. • Switch which is followed by variable name in parentheses called controlling expression. • The break keyword must be included at the end of each case statement. • The break statement causes program control to proceed with the first statement after the switch structure. • Without break statement, all command for that case and next case label will be executed. • Default is an option that will only be executed if suitable case cannot be found.
  • 23. Flowchart Case 1 Case n default Statement for value=1 break break Statement for value=1
  • 24. syntax Switch(expression) { case value 1: statement if expression =value 1 break; case value n: statement if expression =value n break; default: statement if none of the expression is matched }
  • 25. Example of program #include<iostream> using namespace std; int main() { int num; cout<<“n Enter a number:”; cin>>num; switch(num) { case 1: cout<<“Welcome”; break; case 2: cout<<“Bye”; break; default: cout<<“Wrong Number”; } return 0; Output: Enter a number:1 Welcome
  • 26. Example of program without break statement #include<iostream> using namespace std; int main() { int num; cout<<“n Enter a number:”; cin>>num; switch(num) { case 1: cout<<“Welcome”; case 2: cout<<“Bye”; default: cout<<“Wrong Number”; } return 0; Output: Enter a number:1 WelcomeByeWrong Number
  • 27. Example of program #include<iostream> using namespace std; int main() { char grade; cout<<“n Enter a grade (A-D):”; cin>>grade; switch(grade) { case ‘A’: cout<<“Minimun marks is 80”; break; case ‘B’: cout<<“Minimun marks is 60”; break; case ‘C’: cout<<“Minimun marks is 40”; break; case ‘D’: cout<<“Minimun marks is 25”; break; default: cout<<“Mark between 0-24”; } return 0; } Output: Enter a grade (A-D):C Minimun mark is 40
  • 28. • A,B,C, and D are the possible values that can be assigned to the variable grade. • In each case of constant, A to D a statement or sequence of statement would be executed. • You would have noticed that every line has statement under it called break. • The break is the only thing that stop a case statement from continuing all the way down through each case label under it. • In fact if you do not put break in, the program will keep going down in the case statement. Into other case labels, until it reaches the end of break. • However the default part is the codes that would be executed if there were no matching case of constant’s value.
  • 29. Rules for Switch statement • The value of case statement must be an integer or a character constant. • Case statement arrangement is not important. • Default can exist earlier ( but compiler will place it at the end) • Can’t use condition or limit. • Why switch is the best way to write a program:  easy to read  It is a more spesific statement to implement multiple alternative decisions.  It is used to make a decision between many alternative.
  • 30. Comparison of Nested if statement and switch..case statement Nested if statement switch.. case statement #include<iostream> using namespace std; int main() { int code; cout<<“Enter code (1,2 or 3)”; cin>>code; if(code==1) cout<<“Your favourite flavor is vanila”; else if(code==2) cout<<“Your favourite flavor is chocolate”; else if(code==3) cout<<“Your favourite flavor is strawbery” else cout<<“please choose code 1,2 or 3 only”; return 0; } #include<iostream> using namespace std; int main() { int code; cout<<“Enter code (1,2 or 3)”; cin>>code; switch(code) { case1: cout<<“Your favourite flavor is vanila”; break; case2: cout<<“Your favourite flavor is chocolate”; break; case 3: cout<<“Your favourite flavor is strawbery”; default: cout<<“please choose code 1,2 or 3 only”; } return 0; }
  • 31. exercise 1. If the payment RM5,000 to RM10,000, display a message that the customer will be given a free ticket to Langkawi. Otherwise, display a message that the customer will only be given a free lunch at Quality Hotel. Translate the statement above to program segment. 2. You are given the following requirement: a. Your program is able to read the amount of sales for a sale executive. b. If the sale is more than RM10,000 then the commission will be 5% of the sale. Otherwise, the commission is only 3% of the sales. c. Your program is able to calculate the amount of commission by multiply the percentage of commission with sale. d. Your program is able to display the amount of commission to the sale executive. 3. Write a c++ program to find a maximum value of three integers which are a, b and c.
  • 32. exercise 4. You’re given the following requirements: a. Your program is able to read the item code from the keyboard b. The item code determines the price for each item in the shop. The following table shows the prices and charges of 7 items in the shop. c. If the item code is not matched, an error message is dispayed as follows: “Error, this item code is not in the list.” d. For each selected item, the charge is calculated by multiplying the item price and charge rate. e. Then the payment is a summation of item price and charge. Your program is to display this payment. Item Code Price (RM) Charge(%) A 54.00 5 B 65.00 5 C 82.00 5 D 103.00 7 E 150.00 7 F 245.00 10 H 250.00 10
  • 33. exercise 4. NASA Consultant Co Ltd wants to develop a program that can help the consultant to give advice regarding the home loan. The program receives two inputs from the consultant, which are the amount of House Cost in Ringgit Malaysia and years of term applied. Based on these two inputs, the program should be able to calculate the monthly repayment. The table for the interest calculation is provided as follows: The formulae for the monthly repayment calculation are as follows: Interest (RM) = Interest (%) x House cost (RM) House cost with Interest = House Cost (RM) + Interest (RM) Monthly Repayment = House Cost with Interest / ( Year of Term Applied x 12) Year of Term Applied Interest (%) More than or equal to 25 years 7.5 More than or equal to 20 years 6.5 More than or equal to 15 years 5.5 More than or equal to 10 years 4.5 Less than 10 years 4.0
  • 34. Answer for question 1 (if else) #include<iostream> using namespace std; int main() { float payment; cout<<"Please enter your payment:RM"; cin>>payment; if(payment>=5000&&payment<=10000) { cout<<"Free air ticket to Langkawi"; } else { cout<<"Free lunch at Quality Hotel"; } return 0;
  • 35. Answer for question 1 (nested if)#include<iostream> using namespace std; int main() { float payment; cout<<"Please enter your payment:RM"; cin>>payment; if(payment>=5000) { if(payment<=10000) cout<<"Free air ticket to Langkawi"; else cout<<"Free lunch at Quality Hotel"; } else cout<<"Free lunch at Quality Hotel"; return 0; }
  • 36. Answer for question 1 if and if else#include<iostream> using namespace std; int main() { float payment; cout<<"Please enter your payment:RM"; cin>>payment; { if(payment>10000) { cout<<"Free lunch at Quality Hotel"; cout<<"ccc"; } } { if(payment>=5000) { cout<<"Free air ticket to Langkawi"; cout<<"hiii"; } else { cout<<"Free lunch at Quality Hotel"; cout<<"bye"; } } return 0; }
  • 37. Answer for question 2 #include<iostream> using namespace std; int main() { float sale,commission,amount_commission; cout<<"Please enter your sale:RM"; cin>>sale; if(sale>10000) { commission=0.05; } else { commission=0.03; } amount_commission=sale*commission; cout<<"Your amount of commission is:RM"<<amount_commission; return 0; }
  • 38. Answer for question 2 #include<iostream> using namespace std; int main() { float sale,commission,amount_commission; cout<<"Please enter your sale:RM"; cin>>sale; if(sale>10000) { commission=0.05; amount_commission=sale*commission; cout<<"Your amount of commission is:RM"<<amount_commission; } else { commission=0.03; amount_commission=sale*commission; cout<<"Your amount of commission is:RM"<<amount_commission; } return 0; }
  • 39. Answer question 5 #include<iostream> using namespace std; int main() { int a,b,c; cout<<"ENTER FIRST NUMBER:"; cin>>a; cout<<"ENTER SECOND NUMBER:"; cin>>b; cout<<"ENTER THIRD NUMBER:"; cin>>c; cout<<"n*****************************n"; if(a>b&&a>c) { cout<<"MAXIMUM VALUE IS:"<<a; } else if(b>a&&b>c) { cout<<"MAXIMUM VALUE IS:"<<b; } else { cout<<"MAXIMUM VALUE IS:"<<c; } return 0; }
  • 40. Answer for question 6 #include<iostream> using namespace std; int main() { char code; float price,charge_rate,charge,payment; cout<<"ITEM CODE:"; cin>>code; switch(code) { case 'A':price=54.00; charge_rate=0.05; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; case 'B':price=65.00; charge_rate=0.05; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; case 'C':price=82.00; charge_rate=0.05; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break;
  • 41. case 'D':price=103.00; charge_rate=0.07; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; case 'E':price=150.00; charge_rate=0.07; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; case 'F':price=245.00; charge_rate=0.1; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; case 'H':price=250.00; charge_rate=0.1; charge=price*charge_rate; payment=price+charge; cout<<"Your payment is:RM"<<payment; break; default: cout<<"Error, this item code is not in the listn"; } return 0; }
  • 42. Answer for question 7 #include<iostream> Using namespace.std; int main() { float House_cost,monthly_repayment,interest,interest_pay,House_cost_ineterest; int year; cout<<"HOUSE COST IN RM:"; cin>>House_cost; cout<<"YEAR OF TERM APPLIED:"; cin>>year; if(year>=25) { interest=0.75; } else if(year>=20&&year<25) { interest=0.65; } else if(year>=15&&year<20) { interest=0.55; } else if(year>=10&&year<15) { interest=0.45; } else { interest=0.40; } interest_pay=interest*House_cost; House_cost_ineterest=House_cost+interest_pay; monthly_repayment=House_cost_ineterest/(year*12); cout<<"YOUR REPAYMENT A MONTH IS:RM"<<monthly_repayment; return 0; }
  • 43. Repetition structure • Why repetition is needed?? • Suppose we want to add five numbers to find their average. • From what we have learned so far, we could proceed as follows. cin>>num1>>num2>>num3>>num4>>num5; sum= num1>+num2+num3+num4+num5; average=sum/5; • How about we want to add 100 or 1000 numbers ?? • Therefore, repetition structure offers a better way of performing those task.
  • 45. REPETITION STRUCTURE • A programming control structure that allows a series of instructions to be executed more than once. • The similar statement is repeated several times until the condition are fulfilled. • There are three types of loop:  for  while do..while
  • 46. Flowchart of for statement expression statementt False
  • 47. For statement • General form of for structure: for(initialize;condition;counter) Statement block; • The initialize part is used to initialize any variables that may need to be initialized. This part is performed just once at the start of the loop. • The condition part determines wether the loop execution should continue. • If the value of expression is TRUE (non zero), the statement block will be executed otherwise the loop will be terminated. • The counter part typically increments or decrements the loop index. • This performed every time through the loop iteration. • This part is used to increment any variable that may need to be incremented.
  • 48. Example of program #include<iostream> using namespace std; int main() { int num, i,sum; sum=0; for(i=0;i<5;i++) { cout<<“Enter number:”; cin>>num; sum=sum+num; } cout<<“Total of numbers are:”<<sum; return 0; }
  • 49. Flowchart of While statement statementt True False condition
  • 50. While statement • General form: while (expression) statement block; • The first expression evaluated, • If it is True the statement block is executed • If it False, the statement block is skipped • A while structure allow the program to repeat a set of statement as long as the starting condition remains true. “True” is used in the boolean sense snd so the condition for loop to continue must evaluate to true or false. • The program evaluates the condition if it true then the statement inside the braces are executed. • The condition is evaluated again.This will continue untill the condition is false and the program jumps to the next line after the body of the structure. • If only one statement is used in the while loop then the braces are not required.
  • 51. Example of program #include<iostream> using namespace std; int main() { int num, i,sum; i=0; sum=0; while(i<5) { cout<<“Enter number:”; cin>>num; sum=sum+num; i++; } cout<<“Total of numbers are:”<<sum; return 0; } Output: Enter number:10 Enter number:2 Enter number:12 Enter number:4 Enter number:2 Total of numbers are:30
  • 52. Flowchart of do…while statement statementt True False
  • 53. do....while statement • General form: do { statement block; } while(expression); • The do part contains the body and is executed as long as the while condition remains true. • The difference between these two while structure are while loop the condition is evaluated first and if it immediately false, the condition is tested and so guaranteed to be executed at least once.
  • 54. Example of program #include<iostream> using namespace std; int main() { int num, i,sum; i=0; sum=0; do { cout<<“Enter number:”; cin>>num; sum=sum+num; i++; } while(i<5); cout<<“Total of numbers are:”<<sum; return 0; } Output: Enter number:5 Enter number:8 Enter number:12 Enter number:3 Enter number:10 Total of numbers are:38
  • 55. continue and break statement • Two commands that can be included in looping processes are continue and break. • When included continue statement in the body of the loop causes the program to return immediately to the start of the loop and ignore any remaining part of the body. • The break statement causes the program to immediately exit from the loop and resume at the next of the progarm.
  • 56. Example of program (continue) #include<iostream> using namespace std; int main() { int num, i,sum; i=0; sum=0; while(i<5) { i++; if(i==3) continue; cout<<"Enter number "<<i<<":"; cin>>num; sum=sum+num; } cout<<“Total of numbers are:”<<sum; return 0; } Output: Enter number 1:10 Enter number 2: 5 Enter number 4:12 Enter number 5:3 Total of numbers are:30
  • 57. Example of program (break) #include<iostream> using namespace std; int main() { int num, i,sum; i=0; sum=0; while(i<5) { cout<<“Enter number”; cin>>num; sum=sum+num; i++; if(i==3) break; } cout<<“Total of numbers are:”<<sum; return 0; } Output: Enter number:5 Enter number:20 Enter number:10 Total of numbers are:35
  • 58. Difference between the loops structure for while do..while #include<iostream> using namespace std; int main() { for(i=0;i<3;i++) { cout<<“welcome!”; } return 0; } #include<iostream> using namespace std; int main() { i=0; while(i<3) { cout<<“welcome!”; i++; } return 0; } #include<iostream> using namespace std; int main() { i=0; do { cout<<“welcome!”; i++; } while(i<3); return 0; }