•Many a
times, we want a set of instructions to be executed in one situation, and an
entirely different set of instructions to be executed in another situation.
•a decision
control instruction can be implemented in C using:
–The if statement
–The if-else statement
Example of flowchart
example of coding:
#include <stdio.h>
int main (void)
{
int jyear,cyear,serv;
printf("please enter your join year=\n");
scanf("%d",&jyear);
printf("please enter the year now=\n");
scanf("%d",&cyear);
serv = cyear - jyear;
if(serv>3)
{
printf("wahhhh dapat bonus!!\n");
}
scanf("%d",&jyear);
return 0;
}
int main (void)
{
int jyear,cyear,serv;
printf("please enter your join year=\n");
scanf("%d",&jyear);
printf("please enter the year now=\n");
scanf("%d",&cyear);
serv = cyear - jyear;
if(serv>3)
{
printf("wahhhh dapat bonus!!\n");
}
scanf("%d",&jyear);
return 0;
}
No comments:
Post a Comment