04 Making decision GUI
04 Making decision GUI
Flowchart of if Statement
10 October 2023 Programming for Engineers (C language) NV Binh 5
2 Making decisions
2.2 The if statement
C code:
#include<stdio.h>
main(){
int grade;
printf( "Enter your grade :");
scanf("%d", &grade);
if ( grade >= 60 ) {
printf( "Passed\n");
}
}
if(test_expression one)
{
if(test_expression two) {
/*Statement block Executes when the boolean test expression two is true.
*/
}
}
else
{
//else statement block
}
• Syntax
– Series of case labels and an optional default case
switch ( value ){
case '1’:
//actions in case 1
break; //exits from statement
case ‘2’:
//actions in case 1
break; //exits from statement
default:
//actions in default
}
Flowchart of Looping
Flowchart of Looping
}while( condition );
int main ()
{
/* local variable Initialization */ int n
= 1,times=5;
/* do loops execution */ do
{
printf("C do while loops: %d\n", n);
n = n + 1;
}while( n <= times );
return 0;
}
if ( grade >= 60 );
statements