I PUC Unit B
I PUC Unit B
I PUC Unit B
Decision
B C
D E F
THREE MARK QUESTION.
1. What is nested if statement? Write its
syntax.
A statement in which one if statement
included within another if statement is
called nested-if- statement. OR
One if statement within another if is
called nested-if statement.
Example:
for(int i=1; i<=10; i++)
cout<<i<<setw(4);
2. Explain in brief the various stages of
problem solving.
Step 1: Start
Step 2: Input N
Step 3: m=n,sum=0
Step 4: Repeat step 5,6,7 while (n!=0)
Step 5: rem=n%10
Step 6: sum=sum+rem*rem*rem
Step 7: n=n/10
End of while loop
Step 8: if (sum==m) then
Output “It is an Armstrong number”
else
Output “It is not an Armstrong number”
endof if
Step 9: Stop
break;
…..
break;
Example:
switch(dayno)
{ case 1: cout<<”Monday”;
break;
case 2: cout<<”Tuesday”;
break;
case 3: cout<<”Wednesday”;
break;
case 4: cout<<”Thursday”;
break;
case 5: cout<<”Friday”;
break;
case 6: cout<<”Saturday”;
break;
case 7 : cout<<”Sunday”
break;
default :cout<<”Invalid day number”;
}
5. Write an algorithm and draw a flowchart to
find area and circumference of a circle.
Step 1 : start
Step 2: Read rad
Step 3: area= 3.142* rad*rad
circum = 2 * 3.14 * rad
Step 4: Display area , circum
Step 5: Stop
6. What is flow chart? Explain various
symbols used in it.
Flowchart: The diagrammatic
representation of an algorithm is called
flowchart.
Rectangle Process or
Calculation or
Assignment
Rhombus Decision or branching
ALGORITHM EXAMPLE:
FLOWCHART SYMBOLS AND EXAMPLES:
SELECTION STATEMENTS:
SIMPLE IF
SYNTAX: FLOWCHART
IF- ELSE
SYNTAX: FLOWCHART
IF –ELSE-IF
SYNTAX: FLOWCHART
NESTED IF.....
SYNTAX FLOWCHART
SWITCH CASE
SYNTAX
FLOWCHART
ITERATIVE STATEMENTS
WHILE
SYNTAX FLOWCHART
DO-WHILE
SYNATX FLOWCHART
FOR LOOP
SYNTAX
FLOWCHART