ACLC College Computer Programming1 C SESSION9
ACLC College Computer Programming1 C SESSION9
(C++)
Gliceria S. Tan
Instructor
Session 9 Topics
➢ Control Structures
➢ Decision Structures
Syntax:
if (expression)
statement;
or
if (expression) {
statement;
Block or statement block
…
}
GLICERIA S. TAN, MIS COMPUTER PROGRAMMING 1
INSTRUCTOR
For example:
int grade = 68;
if( grade > 60 )
cout<<"Congratulations!";
or
int grade = 68;
if( grade > 60 ) {
cout<<"Congratulations! “<<endl;
cout<<"You passed!";
}
GLICERIA S. TAN, MIS COMPUTER PROGRAMMING 1
INSTRUCTOR
The if-else statement
Syntax:
if(expression)
statement1;
else
statement2;
if(x) {
if (y)
cout<<“1”;
}
else
cout<<“2”;