CS 111 Computing Fundamentals: Selection (2) - Bool Iteration (1) Dr. Christina Class
CS 111 Computing Fundamentals: Selection (2) - Bool Iteration (1) Dr. Christina Class
Fundamentals
Selection (2)
_Bool
Iteration (1)
Dr. Christina Class
Repetition
nested if
printing the maximum of three values
int main()
{
int a = 5;
if (a==5) {
printf("a is 5\n");
}
if (a==10) {
printf("a is 10\n");
}
else {
printf("else case");
}
return 0;
}
int main()
{
int studentType;
if(studentType == 1) {
printf("Bachelor Student\n");
} else if (studentType == 2) {
printf("Master Student\n");
} else if(studentType == 3) {
printf("PhD Student\n");
} else {
printf("invalid student type\n");
}
return 0;
}
if(studentType == 1) {
printf("Bachelor Student\n");
} else if (studentType == 2) {
printf("Master Student\n");
} else if(studentType == 3) {
printf("PhD Student\n");
} else {
printf("invalid student type\n");
}
int i = 1;
while (i <= 100) {
printf(“%d: %d”, i, i*i);
i += 1;
}
int main(void)
{
int u,v,temp;
return 0;
}