C7.5: Control Structures Flashcards

1
Q

What are the two types of control structures?

A

Selection and loops.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the different types of selection?

A

if statement, switch statement, conditional operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the three kinds of loops?

A

while loop, do while loop and for loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give an example of a switch statement.

A
int x = 2; 
   switch (x) 
   { 
       case 1: printf("Choice is 1"); 
               break; 
       case 2: printf("Choice is 2"); 
                break; 
       case 3: printf("Choice is 3"); 
               break; 
       default: printf("Choice other than 1, 2 and 3"); 
                break;   
   }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give an example of a do while loop.

A

do{
printf(ā€œ%d \nā€,i);
i++;
}while(i<=10);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly