- Difference between conditional and looping statement
Conditional statement executes only once in the program where as looping statements executes repeatedly several number of time.
- What is a nested loop?
A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop that is inside an outer loop. In this scenario, the inner loop is performed a number of times as specified by the outer loop. For each turn on the outer loop, the inner loop is first performed.
- When is a “switch” statement preferable over an “if” statement?
The switch statement is best used when dealing with selections based on a single variable or expression. However, switch statements can only evaluate integer and character data types.
- Why we use do-while loop in c? Also tell any properties which you know?
It is also called as post tested loop. It is used when it is necessary to execute the loop at least one time. Syntax:
} while (Expression);
printf(“To enter press 1\n”);
printf(“To exit press 2”);
case 1:printf(“You are welcome\n”);break;
default : exit(0);
Output: 3 3 4 4
- What is the use of “goto” statement?
goto statement is used to transfer the normal flow of a program to the specified in the program. Below is the syntax for goto statement in C.
- What is the output of this C code?
int a = 0, i = 0, b;
For (i = 0;i < 5; i++)