Here are some C programs which is related to the control structures With the detailed explanation, guess the output of the following programs:-
1.what will be the output of the below program?
3. No Output
The answer is option(3).
Explanation:The switch case control structure execute the statement present in the case. But in the above program, the outer switch does not has cases. Therefore, control does not enter inside the switch case. Thus, the program does not give any output and compiler does not produce any error.
2.Guess the correct answer of the mentioned program?
1. Abnormal termination
2. Compile time error
3. No output
The output is option(4).
Explanation: In the above program, value of x is 2 so case 2 will execute and it will print Hello.
3.How many times does the loop run?
1. 5 times
2. 15 times
3. 10 times
4. 20 times
The answer is option(1).
Explanation: Here the loop print GFG five times. Because when the for loop counter value i.e. i is 5, the break statement will transfer the control to outside loop.
4.what will be the output?
1. print welcome 5 times
2. print hii 5 times
3. print hii 10 times
4. print welcome 10 times
The answer is option(4).
Explanation : When the control of the for loop reaches continue statement, the control automatically transfers to the beginning of the loop and leave the printf(“hii”); statement.
5.How many time the program will print?
1. print 2 times
3. print 10 times
4. print 5 times
The answer is option(2).
Explanation: Because the value 100 is assigned to i every time and it does not check for any condition because here there is no = sign in the for loop. Therefore the loop goes into infinite loop.
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.