In structured programming, we sub-divide the whole program into small modules so that the program becomes easy to understand. The purpose of structured programming is to linearize control flow through a computer program so that the execution sequence follows the sequence in which the code is written. The dynamic structure of the program than resemble the static structure of the program. This enhances the readability, testability, and modifiability of the program. This linear flow of control can be managed by restricting the set of allowed applications construct to a single entry, single exit formats.
Roadmap to Membership of RICS - Pathways and Routes
Question Pattern in Structure Programming
1. QUESTION PATTERN IN STRUCTURE PROGRAMMING
Course No : CSE 0613-101
Course Title : Structure Programming
Suman Saikan
Lecturer
Dept. of CSE
Dhaka International University
1
2. INTRODUCTION
Definition of Structure Programming Language
Structured Programming is a type of programming that
generally converts large or complex programs into more
manageable and small pieces of code.
2
4. DESCRIBE DIFFERENT KINDS OF LOOP WITH EXAMPLE
Loops in programming are used to repeat a block of code until
the specified condition is met. A loop statement allows
programmers to execute a statement or group of statements
multiple times without repetition of code.
4
5. For Loop
for loop in C programming is a repetition control structure that
allows programmers to write a loop that will be executed a
specific number of times. for loop enables programmers to
perform n number of steps together in a single line.
Syntax:
for (initialize expression; test expression; update
expression)
{
// // body of for loop // ;
}
5
6. While Loop
While loop does not depend upon the number of iterations.
In for loop the number of iterations was previously known to
us but in the While loop, the execution is terminated on the
basis of the test condition. If the test condition will become
false then it will break from the while loop else body will be
executed.
Syntax:
initialization_expression;
while (test_expression)
{
// body of the while loop
update_expression;
}
6
7. Do-while Loop
The do-while loop is similar to a while loop but the
only difference lies in the do-while loop test
condition which is tested at the end of the body. In
the do-while loop, the loop body will execute at
least once irrespective of the test condition.
Syntax:
initialization_expression;
do {
// body of do-while loop update_expression;
} while (test_expression);
7
8. EXPLAIN INFINITE LOOP BY USING FOR LOOP
Infinite Loop
An infinite loop is executed when the test expression never becomes
false and the body of the loop is executed repeatedly. A program is
stuck in an Infinite loop when the condition is always true. Mostly this is
an error that can be resolved by using Loop Control statements.
8
9. Example of Infinite Loop:
#include <stdio.h>
int main ()
{
int i;
for ( ; ; )
{
printf("This loop will run forever.n");
}
return 0;
}
9
10. ILLUSTRATE RECURSION IN STRUCTURE PROGRAMMING
Recursion is the technique of making a function call itself. This
technique provides a way to break complicated problems down into
simple problems which are easier to solve.
10
13. WHAT IS OPERATOR PRECEDENCE IN C
Operator precedence determines the grouping of terms in an expression and
decides how an expression is evaluated. Certain operators have higher
precedence than others
13
14. FIND ERROR AND SOLVE IT IN C
Problem:
#include <stdio,h>
int main()
{
int a=2;
if(A>1)
Printf("a is greater than 1")
return 0;
}
Solution:
#include <stdio.h>
int main()
{
int a=2;
if(a>1)
printf("a is greater than 1");
return 0;
}
14
15. EXPLAIN THE OUTPUT OF A C PROGRAM
#include<stdio.h>
int main()
{
int i;
for(i=0;i<10;i++)
{
if(i==5)
break;
}
printf("%d",i);
} 15