SEE Computer Modular Programming Questions

 SEE Computer Modular Programming Questions

Due to studying on online platform, some queries can't be solved. So our team has made SEE Computer Modular Programming Questions which are often confused. In all possible way, we have tried to clear your confusions. If any problems faced, kindly comment we will try to solve the problems as soon as possible. We hope that this will help you alot.

SEE Computer Modular Programming Questions


Write the programs to solve the following problems:

Write a program to declare sub procedure modules to find and return product of digits of an input number.
Ans:

DECLARE SUB PRODUCT (N)

CLS

INPUT “ENTER ANY NUMBER”; N

CALL PRODUCT (N)

END

                SUB PRODUCT (N)

                A = 1

                WHILE N <> 0

                R = N MOD 10

                A = A * R

                N = N \ 10

                WEND

                PRINT “PRODUCT OF DIGITS”; A

                END SUB

 

WAP to read the value of base and exponent, increase the power of base to the exponent using function.

ANS:

DECLARE FUNCTION NUM (A, B)

CLS

INPUT “ENTER A BASE”; A

INPUT “ENTER THE EXPONENT FOR BASE”; B

PRINT “INCREMENT OF POWER OF BASE TO EXPONENT”; NUM (A, B)

END

                FUNCTION NUM (A, B)

                C = A ^ B

                NUM = C

                END FUNCTION

 

WAP to print factorial number of first 10 natural numbers.

ANS:

DECLARE SUB FACT (F)

CLS

CALL FACT (F)

END

                SUB FACT (F)

                F = 1

                FOR I = 1 TO 10

                FOR J = 1 TO I

                F = F * J

NEXT J

PRINT F

F = 1 (If output doesn’t come then try F = F / F in this step)

NEXT I

END SUB

(NOTE: The above can’t be made by FUNCTION procedure

But if asked then do the following, but the output will be only factorial of 10 i.e. 3628800)

By Function Procedure

DECLARE FUNCTION FACT (F)

CLS

PRINT FACT (F)

END

                FUNCTION FACT (F)

                F = 1

                FOR I = 1 TO 10

                FOR J = 1 TO I

                F = F * J

                NEXT J

                FACT = F

                F = 1

                NEXT I

                END FUNCTION

 

WAP to convert decimal into binary number using function…end function.

Ans:

 DECLARE FUNCTION BINARY (N)

CLS

INPUT “ENTER DECIMAL NUMBER”; N

PRINT “BINARY NUMBER IS”; BINARY (N)

END

                FUNCTION BINARY (N)

                WHILE N <> 0

    R = N MOD 2

    B$ = STR$ (R) + B$

    N = N \ 2

    WEND

    B = VAL (B$)

    BINARY = B

    END FUNCTION

 

WAP to convert Binary into decimal number using FUNCTION.

Ans:

DECLARE FUNCTION DECIMAL (N)

CLS

INPUT “ENTER BINARY NUMBER”; N

PRINT “DECIMAL NUMBER IS”; DECIMAL (N)

END

                FUNCTION DECIMAL (N)

                P = 0

                WHILE N <> 0

                R = N MOD 10

                SUM = SUM + (R*2) ^ P

                N = N \ 10

                WEND

                DECIMAL = SUM

                END FUNCTION

 

WAP to print sum of individual even digits using function…… end function.

Ans:

DECLARE FUNCTION SUM (A)

CLS

INPUT “ENTER ANY NUMBER”; A

PRINT “SUM OF INDIVIDUAL EVEN DIGITS”; SUM (A)

END

                FUNCTION SUM (A)

                WHILE A <> 0

                B = A MOD 10

                IF B MOD 2 = 0 THEN

                C = C + B

                END IF

                A = A \ 10

                WEND

                SUM = C

                END FUNCTION

 

WAP to check whether the given number is palindrome or not.

Ans:

DECLARE FUNCTION CHECK$ (A$)

CLS

INPUT “ENTER ANY STRING”; A$

IF A$ = CHECK$ (A$) THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END

                FUNCTION CHECK$ (A$)

                FOR I = LEN (A$) TO 1 STEP -1

    B$ = B$ + MID$ (A$, I, 1)

    NEXT I

                CHECK$ = B$

                END FUNCTION

 

WAP to count total number of factors in the given number.

Ans:

DECLARE SUB FACTORS (N)

CLS

INPUT “ENTER ANY NUMBER”; N

CALL FACTORS (N)

END

                SUB FACTORS (N)

                FOR I = 1 TO N

                R = N MOD I

                IF R = 0 THEN

                F = F + 1

                END IF

                NEXT I

                PRINT “TOTAL NUMBER OF FACTORS”; F

                END SUB

 

WAP to concatenate (link) three different strings input by a user as illustrated below in the hint given using a user-defined function named STRCONC ().

(HINT: If the input strings are “FIRST”, “SECOND” and “THIRD” then output is “FIRSTSECONDTHIRD”)

Ans:

DECLARE SUB STRCONC (A$, B$, C$)

CLS

INPUT “ENTER A STRING”; A$

INPUT “ENTER SECOND STRING’; B$

INPUT “ENTER THIRD STRING”; C$

CALL STRCONC (A$, B$, C$)

END

                SUB STRCONC (A$, B$, C$)

                E$ = A$ + B$ + C$

                PRINT “CONCATENATE IS”; E$

                END SUB

 

WAP to produce the following:

1, 2, 3, 5, 8, 13, ………… 20th terms

Ans:

DECLARE SUB FIBONIC (A, B, C)

CLS

CALL FIBONIC (A, B, C)

END

                SUB FIBONIC (A, B, C)

                A = 1

                B = 2

                PRINT A; B;

                FOR I = 1 TO 18

                C = A + B

                PRINT C:

                A = B

                B = C

                NEXT I

                END SUB

(NOTE: FIBONIC SERIES questions can’t be made using function………end function.)

 

A sequential data file “Result.dat” contains name of the student, class, roll no., total marks, percentage. WAP to display and copy some records in “NEwresult.dat” as per user’s choice.

Ans:

CLS

OPEN “RESULT.dat” FOR INPUT AS #15

OPEN “NEWRESULT.dat” FOR OUTPUT AS #16

WHILE NOT EOF (15)

INPUT #15 N$, C, R, T, P

PRINT “NAMEOF THE STUDENT”; N$

PRINT “CLASS”; C

PRINT “ROLL NO”; R

PRINT “TOTAL MARKS”; T

PRINT “PERCENTAGE”; P

INPUT “DO YOU WANT TO COPY RECORDS (Y/N)”; ANS$

IF ANS$ = “Y” THEN

WRITE #16 N$, C, R, T, P

END IF

CLOSE #15

CLOSE #16

 

A sequential data file “Salary.dat” contains name of staff, address, post, and salary. WAP to display and delete some records.

Ans:

CLS

OPEN “SALARY.dat” FOR INPUT AS #10

OPEN “NEWSALARY.dat” FOR OUTPUT AS#11

WHILE NOT EOF (10)

INPUT #10 N$, A$, P$, S

PRINT “NAME OF STAFF”; N$

PRINT “ADDRESS”; A$

PRINT “POST”; P$

PRINT “SALARY”; S

INPUT “DO YOU WANT TO DELETE THIS RECORD (Y/N)”; ANS$

IF ANS$ = “N” THEN

WRITE #11 N$, A$, P$, S

END IF

WEND

CLOSE #10

CLOSE #11

KILL “SALARY.dat”

END

WAP to input name, address and post of some employees and store them in a file named “EMP.dat” along with serial number.

Ans:

CLS

OPEN “EMP.dat” FOR OUTPUT AS #1

DO

INPUT “ENTER SERIAL NUMBER”; SN

INPUT “ENTER NAME OF STAFF”; N$

INPUT “ENTER POST”; P$

INPUT “ENTER SALARY”; S

WRITE #1 SN, N$, P$, S

INPUT “DO YOU WANT TO ADD MORE RECORDS (Y/N)”; ANS$

LOOP WHILE ANS$ = “Y”

CLOSE #1

END

 

A sequential data file “student.dat” contains some records under field name, English, nepali, and computer. WAP to add some more records in the same file.

Ans:

CLS

OPEN “STUDENT.dat” FOR APPEND #1

DO

INPUT “NAME OF STUDENT”; N$

INPUT “ENGLISH MARKS”; E

INPUT “ENTER NEPALI MARKS”; N

INPUT “ENTER COMPUTER MARKS”; C

WRITE #1 N$, E, N, C

INPUT “DO YOU WANT TO ADD SOME MORE RECORDS (Y/N)”; ANS$

LOOP WHILE ANS$ = “Y”

CLOSE #1

END

 

Study the following program and answer the questions.

DECLARE FUNCTION CHK$ (N)

CLS

N = 57

PRINT “THE NUMBER IS”; CHK$ (N)

END

                FUNCTION CHK$ (N)

                FOR I = 1 TO N

                IF N MOD I = 0 THEN

C = C + 1

NEXT I

END IF

IF C > 2 THEN

CHK$ = “COMPOSITE”

ELSE

CHK$ = “PRIME”

END IF

END FUNCTION

 #SEE Computer Modular Programming Questions

Leave your compliments in the comment section below...

4 comments:

  1. Fantastic piece of content! Take into consideration was pleased with the actual checking. I’m hoping you just read a bit more of you. I know you’ve gotten really good comprehension coupled with plans. Quite possibly very highly delighted utilizing this facts. TSA

    ReplyDelete
  2. There are quite a few U.S. based, remote computer repair companies with English speaking, certified technician's to choose from. KombDev Philadelphia IT services

    ReplyDelete

Powered by Blogger.