Notes On Modular Programming
Notes On Modular Programming
PROGRAMMING
MODULAR PROGRAMMING
• Modular programming is a technique used to divide our program into
many small logical, manageable and functional modules or blocks.
Every modular program has one main module and may have many
sub modules. The sub module of a program is also called as
procedure.
DECLARE SUBTEST(N)
CLS
INPUT "Enter a number"; N
CALL TEST(N)
END
SUB TEST(N)
IF N>0 THEN
PRINT N; "is positive number"
ELSE
PRINT N; "is negative number"
END IF
END SUB
WAP to calculate perimeter of rectangle using sub
procedures
•
• DECLARE SUB REVERSE (N$)
• CLS
• INPUT “ENTER ANY STRING”; N$
• CALL REVERSE(N$)
• END
• SUB REVERSE (N$)
• FOR I = 1 TO LEN(N$)
• B$ = MID$(S$, I, 1) + B$
• NEXT I
• PRINT “REVERSED STRING IS “; B$
• END SUB
WAP to check wheather a number is armstrong or not using SUB
and SUB END…
• DECLARE SUB ARMS (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL ARMS(N)
END
SUB ARMS (N)
A=N
S=0
WHILE N <> 0
R = N MOD 10
S=S+R^3
N = N \ 10
WEND
IF A = S THEN
PRINT A; "IS ARMSTRONG NUMBER"
ELSE
PRINT A; "IS NOT ARMSTRONG NUMBER"
END IF
END SUB
Write a program to generate the series using SUB …… END SUB : -10, -8,
-6, -4, ………. Up to 20th term.