MODULAR PROGRAMMING (EXERCISE 2)


 

#WAP TO CHECK WHETHER THE ENTERED NUMBER IS DIVISIBLE BY 5 AND 7 OR NOT.

DECLARE SUB CHECK(N)

CLS

INPUT “ENTER ANY NUMBER”;N

CALL CHECK(N)

END

SUB CHECK(N)

IF N MOD 5=0 AND N MOD 7=0  THEN

PRINT “THE NO. IS DIVISIBLE BY 5 AND 7”

ELSE

PRINT “THE NO. IS NOT DIVISIBLE BY 5 AND 7”

END IF

END SUB

 

#WAP TO ENTER THE AGE OF A PERSON. IF THE AGE IS ABOVE 18, THE PROGRAM PRINTS “YOU CAN VOTE”. OTHERWISE, THE PROGRAM PRINTS “YOU CANNOT VOTE”.

DECLARE SUB CHECK(A)

CLS

INPUT “ENTER THE AGE OF A PERSON”;A

CALL CHECK(A)

END

SUB CHECK(A)

IF A>18 THEN

PRINT “YOU  CAN VOTE”

ELSE

PRINT “YOU CANNOT VOTE”

END IF

END SUB

 

#WAP TO CHECK WHETHER THE ENTERED NUMBER IS ODD OR EVEN.

DECLARE SUB CHECK(N)

CLS

INPUT “ENTER ANY NUMBER”;N

CALL CHECK(N)

END

SUB CHECK(N)

IF N MOD 2=0 THEN

PRINT “THE NUMBER IS EVEN”

ELSE

PRINT “THE NUMBER IS ODD”

END IF

END SUB

 

#WAP TO ENTER ANY TWO NUMBERS AND PRITN THE GREATEST AMONG TWO.

DECLARE SUB GREATER(A,B)

CLS

INPUT “ENTER ANY TWO NUMBERS”;A,B

CALL GREATER(A,B)

END

SUB GREATER(A,B)

IF A>B THEN

PRINT “A IS GREATER”

ELSE

PRINT “B IS GREATER”

END IF

END SUB

 

#WAP TO ENTER ANY THREE NUMBERS AND PRINT THE GREATEST AMONG THREE.

DECLARE SUB ABC(X,Y,Z)

CLS

INPUT “ENTER ANY THREE NUMBERS”;X,Y,Z

CALL ABC(X,Y,Z)

END

SUB ABC(X,Y,Z)

IF X>Y AND X>Z THEN G=X

IF Y>X AND Y>Z THEN G=Y

IF Z>X AND Z>Y THEN G=Z

PRINT “THE GREATEST NUMBER IS=”;G

END SUB

 

#WAP TO ASK ANY THREE NUMBERS AND DISPLAY THE DIFERENCE BETWEEN THE GREATEST AND SMALLEST NUMBER.

DECLARE SUB DIFFERENCE(A,B,C)

CLS

INPUT “ENTER ANY  THREE NUMBERS”;A,B,C

CALL DIFFERENCE(A,B,C)

END

SUB DIFFERENCE(A,B,C)

IF A>B AND A>C THEN G=A

IF B>A AND B>C THEN G=B

IF C>A AND C>B THEN G=C

PRINT “THE GREATEST NUMBER IS”;G

IF A<B AND A<C THEN S=A

IF B<A AND B<C THEN S=B

IF C<A AND C<B THEN S=C

PRINT “THE SMALLEST NUMBER IS=”;S

DIFF=G-S

PRINT “THE DIFFERENCE OF GREATEST AND SMALLEST NUMBER=”;DIFF

END SUB

 

#WAP TO PRINT THE MIDDLE NUMBER AMONG ANY THREE ENTERED NUMBERS. [IF 3, 5, 1 ARE ENTERED NUMBERS, THE MIDDLE NUMBER IS 3]

DECLARE SUB CHECK(A,B,C)

CLS

INPUT “ENTER ANY THREE NUMBERS”;A,B,C

CALL CHECK(A,B,C)

END

SUB CEHCK(A,B,C)

IF (A<B AND A>C) OR (A>B AND A<C) THEN MIDDLE=A

IF (B<A AND B>C) OR (B>A AND B<C) THEN MIDDLE=B

IF (C<A AND C>B) OR (C>A AND C<B) THEN MIDDLE=C

PRINT “THE MIDDLE NUMBER IS=”;MIDDLE

END SUB

 

#WAP TO ENTER MONTHLY INCOME AND THEN COMPUTE ANNUAL TAX TO BE PAID. THE TAX RATE IS 15% IF THE ANNUAL INCOME IS ABOVE 200000. OTHERWISE, TAX RATE IS 1%.

DECLARE SUB TAX(N)

CLS

INPUT “ENTER MONTHLY INCOME”;N

CALL TAX(N)

END

SUB TAX(N)

ANNUAL INCOME=12*N

IF ANNUAL INCOME>200000 THEN

TA=(15/100)*ANNUAL INCOME

ELSE

TA=(1/100)*ANNUAL INCOME

END IF

PRINT “TOTAL TAX TO BE PAID=”;TA

END SUB

 

#WAP TO CHECK WHETHER THE ENTERED NUMBER IS DIVISIBLE BY 5 AND 7 OR NOT.

DECLARE SUB CHECK(N)

CLS

INPUT “ENTER ANY NUMBER”;N

CALL CHECK(N)

END

SUB CHECK(N)

IF N MOD 5=0 AND N MOD 7=0  THEN

PRINT “THE NO. IS DIVISIBLE BY 5 AND 7”

ELSE

PRINT “THE NO. IS NOT DIVISIBLE BY 5 AND 7”

END IF

END SUB

 

#WAP TO ENTER THE AGE OF A PERSON. IF THE AGE IS ABOVE 18, THE PROGRAM PRINTS “YOU CAN VOTE”. OTHERWISE, THE PROGRAM PRINTS “YOU CANNOT VOTE”.

DECLARE SUB CHECK(A)

CLS

INPUT “ENTER THE AGE OF A PERSON”;A

CALL CHECK(A)

END

SUB CHECK(A)

IF A>18 THEN

PRINT “YOU  CAN VOTE”

ELSE

PRINT “YOU CANNOT VOTE”

END IF

END SUB

 

#WAP TO CHECK WHETHER THE ENTERED NUMBER IS ODD OR EVEN.

DECLARE SUB CHECK(N)

CLS

INPUT “ENTER ANY NUMBER”;N

CALL CHECK(N)

END

SUB CHECK(N)

IF N MOD 2=0 THEN

PRINT “THE NUMBER IS EVEN”

ELSE

PRINT “THE NUMBER IS ODD”

END IF

END SUB

 

#WAP TO ENTER ANY TWO NUMBERS AND PRITN THE GREATEST AMONG TWO.

DECLARE SUB GREATER(A,B)

CLS

INPUT “ENTER ANY TWO NUMBERS”;A,B

CALL GREATER(A,B)

END

SUB GREATER(A,B)

IF A>B THEN

PRINT “A IS GREATER”

ELSE

PRINT “B IS GREATER”

END IF

END SUB

 

#WAP TO ENTER ANY THREE NUMBERS AND PRINT THE GREATEST AMONG THREE.

DECLARE SUB ABC(X,Y,Z)

CLS

INPUT “ENTER ANY THREE NUMBERS”;X,Y,Z

CALL ABC(X,Y,Z)

END

SUB ABC(X,Y,Z)

IF X>Y AND X>Z THEN G=X

IF Y>X AND Y>Z THEN G=Y

IF Z>X AND Z>Y THEN G=Z

PRINT “THE GREATEST NUMBER IS=”;G

END SUB

 

#WAP TO ASK ANY THREE NUMBERS AND DISPLAY THE DIFERENCE BETWEEN THE GREATEST AND SMALLEST NUMBER.

DECLARE SUB DIFFERENCE(A,B,C)

CLS

INPUT “ENTER ANY  THREE NUMBERS”;A,B,C

CALL DIFFERENCE(A,B,C)

END

SUB DIFFERENCE(A,B,C)

IF A>B AND A>C THEN G=A

IF B>A AND B>C THEN G=B

IF C>A AND C>B THEN G=C

PRINT “THE GREATEST NUMBER IS”;G

IF A<B AND A<C THEN S=A

IF B<A AND B<C THEN S=B

IF C<A AND C<B THEN S=C

PRINT “THE SMALLEST NUMBER IS=”;S

DIFF=G-S

PRINT “THE DIFFERENCE OF GREATEST AND SMALLEST NUMBER=”;DIFF

END SUB

 

#WAP TO PRINT THE MIDDLE NUMBER AMONG ANY THREE ENTERED NUMBERS. [IF 3, 5, 1 ARE ENTERED NUMBERS, THE MIDDLE NUMBER IS 3]

DECLARE SUB CHECK(A,B,C)

CLS

INPUT “ENTER ANY THREE NUMBERS”;A,B,C

CALL CHECK(A,B,C)

END

SUB CEHCK(A,B,C)

IF (A<B AND A>C) OR (A>B AND A<C) THEN MIDDLE=A

IF (B<A AND B>C) OR (B>A AND B<C) THEN MIDDLE=B

IF (C<A AND C>B) OR (C>A AND C<B) THEN MIDDLE=C

PRINT “THE MIDDLE NUMBER IS=”;MIDDLE

END SUB

 

#WAP TO ENTER MONTHLY INCOME AND THEN COMPUTE ANNUAL TAX TO BE PAID. THE TAX RATE IS 15% IF THE ANNUAL INCOME IS ABOVE 200000. OTHERWISE, TAX RATE IS 1%.

DECLARE SUB TAX(N)

CLS

INPUT “ENTER MONTHLY INCOME”;N

CALL TAX(N)

END

SUB TAX(N)

ANNUAL INCOME=12*N

IF ANNUAL INCOME>200000 THEN

TA=(15/100)*ANNUAL INCOME

ELSE

TA=(1/100)*ANNUAL INCOME

END IF

PRINT “TOTAL TAX TO BE PAID=”;TA

END SUB

 


Sujit Prasad Kushwaha

A Dedicated Blogger Sharing Insights and Making a Difference.

Post a Comment

The comment section is your chance to make your mark. Don't hold back - add to the discussion and let your personality shine through!

Previous Post Next Post