Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

VU Past Papers CS201- Midterm Solved Questions on Structured Programming in C/C++

Q#1: What happens when a continue statement is encountered in a while loop?
Answer: When a continue statement is executed in a while loop, the control immediately goes back to the loop’s condition. If the condition is true, the loop continues with the next iteration; otherwise, it exits. It is important to update the loop variable (increment/decrement) before the continue statement to avoid an infinite loop.


Q#2: How does the behavior of continue differ between for and while loops?
Answer: In a for loop, when continue is executed, the loop variable (counter) is automatically updated according to the increment/decrement expression before the next iteration. In a while loop, the programmer must manually update the loop variable before the next iteration; otherwise, it may cause an infinite loop.


Q#3: Why is the use of the goto statement discouraged in structured programming?
Answer: The goto statement is discouraged because it creates unstructured and difficult-to-follow code, often called “spaghetti code.” Using goto makes programs harder to understand, debug, and maintain. Structured programming prefers sequences, decisions, and loops for clarity and maintainability.


Q#4: What is the significance of the single entry and single exit rule in program modules?
Answer: The single entry and single exit rule ensures that each module has only one starting point and one exit point. This simplifies program flow, makes the code easier to debug, improves readability, and prevents complex branching. It helps maintain a structured and easily traceable program, avoiding the confusion caused by multiple exit points.

Contents Copyrights Reserved By T4Tutorials