Question Bank Theory C Programming
Question Bank Theory C Programming
Q2) Explain the usage of break, labelled break, continue and labelled continue
statements?
Ans. In C programming, break and continue are control flow statements used to
alter the normal execution of loops or switch statements. While labelled break and
labelled continue are not directly supported in C, similar behavior can be achieved
using the goto statement. Below are detailed explanations of each
1. break Statement
The break statement is used to:
• Exit a for, while, or do-while loop prematurely.
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
2
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
3
Output:
i=0, j=0
i=0, j=1
i=0, j=2
i=1, j=0
Exited nested loops.
3. continue Statement
The continue statement is used to:
• Skip the rest of the code in the current iteration of a loop.
• Immediately proceed to the next iteration of the loop.
Example:
for (int i = 0; i < 5; i++) {
if (i == 3) {
continue; // Skip printing when i equals 3
}
printf("%d ", i);
}
// Output: 0 1 2 4
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
4
next_iteration:;
}
Output:
i=0, j=0
i=0, j=1
i=0, j=2
i=1, j=0
i=1, j=2
i=2, j=0
i=2, j=1
i=2, j=2
Comparison of Statements
Statement Purpose
Skips the remaining part of the loop body for the current iteration
continue
and moves to the next iteration.
Labelled Skips nested iterations using goto (since C lacks direct support for
continue labelled continue).
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
5
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
6
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)
7
*****
***
*
Q67) Write a program to read 4 digit number and find average of those digits.
Q68) What is the use of goto statement? Explain with program.
Q69) What is a Macro? Explain parameterized and non parameterized macros.
Q70) Explain about fprintf and fscanf function.
Q71) What is type casting? Explain various types of type casting.
Q72) Explain basic structure of C Program.
Q73) Write a peogram in C to concatenate two strings.
Q74) What is an expression? Explain the precedence of operators and associativity.
Q75) Explain formatted console i/o function. Also write various format specifiers used
with these function.
Youtube : Anjali Luthra, Instagram : aec_computer_education, Linkedin : Anjali Luthra, Google Play Store: ALCoders
Courses Available for Computer Science related Subjects for School(CBSE, ISC, IB) & College (BCA, B.Tech, B.Sc. CS & IT)