QUESTION PATTERN IN STRUCTURE PROGRAMMING
Course No : CSE 0613-101
Course Title : Structure Programming
Suman Saikan
Lecturer
Dept. of CSE
Dhaka International University
1
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
DISTINGUISH BETWEEN STRUCTURE PROGRAMMING AND OBJECT
ORIENTED PROGRAMMING
3
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
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
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
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
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
Example of Infinite Loop:
#include <stdio.h>
int main ()
{
int i;
for ( ; ; )
{
printf("This loop will run forever.n");
}
return 0;
}
9
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
DISTINGUISH BETWEEN POST INCREMENT AND PRE INCREMENT
11
CALL BY VALUE AND CALL BY REFERENCE
12
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
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
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
SWAP TWO VARIABLE WITHOUT USING THIRD VARIABLE
16
WRITE THE OUTPUT OF THIS FOLLOWING CODE
17
FLOWCHART OF CONDITIONAL STATEMENT
Flowchart of if statement in C
18
Flowchart of the if-else statement in C
19
FLOWCHART OF CONDITIONAL STATEMENT
FLOWCHART OF CONDITIONAL STATEMENT
Flowchart of else-if ladder statement in C
20
21

Question Pattern in Structure Programming

  • 1.
    QUESTION PATTERN INSTRUCTURE PROGRAMMING Course No : CSE 0613-101 Course Title : Structure Programming Suman Saikan Lecturer Dept. of CSE Dhaka International University 1
  • 2.
    INTRODUCTION Definition of StructureProgramming Language Structured Programming is a type of programming that generally converts large or complex programs into more manageable and small pieces of code. 2
  • 3.
    DISTINGUISH BETWEEN STRUCTUREPROGRAMMING AND OBJECT ORIENTED PROGRAMMING 3
  • 4.
    DESCRIBE DIFFERENT KINDSOF 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 loopin 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 loopdoes 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-whileloop 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 LOOPBY 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 InfiniteLoop: #include <stdio.h> int main () { int i; for ( ; ; ) { printf("This loop will run forever.n"); } return 0; } 9
  • 10.
    ILLUSTRATE RECURSION INSTRUCTURE 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
  • 11.
    DISTINGUISH BETWEEN POSTINCREMENT AND PRE INCREMENT 11
  • 12.
    CALL BY VALUEAND CALL BY REFERENCE 12
  • 13.
    WHAT IS OPERATORPRECEDENCE 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 ANDSOLVE 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 OUTPUTOF A C PROGRAM #include<stdio.h> int main() { int i; for(i=0;i<10;i++) { if(i==5) break; } printf("%d",i); } 15
  • 16.
    SWAP TWO VARIABLEWITHOUT USING THIRD VARIABLE 16
  • 17.
    WRITE THE OUTPUTOF THIS FOLLOWING CODE 17
  • 18.
    FLOWCHART OF CONDITIONALSTATEMENT Flowchart of if statement in C 18
  • 19.
    Flowchart of theif-else statement in C 19 FLOWCHART OF CONDITIONAL STATEMENT
  • 20.
    FLOWCHART OF CONDITIONALSTATEMENT Flowchart of else-if ladder statement in C 20
  • 21.