1.What is a library function ? list any three library functions.

 A function is a built-in formula or a ready made program which helps us to perform a certain task such as mathematical, financial, logical etc.

 



2.What  are the differences between library function and user defined function.


Library FunctionUser Defined Functions
  • LF(library functions) are Predefined functions. 
  • UDF(user defined functions) are the function which r created by user as per his own requirements.
  • UDF are part of the program which compile runtime
  • LF are part of header file
    (such as MATH.h) which is called runtime.
  • In UDF the name of function id decided by user
  • in LF it is given by developers.
  • in UDF name of function can be changed any time
  • LF Name of function can't be
    changed.
Example : SIN, COS, PowerExample : fibo, mergeme



3 Write a program that count vowels and consonants in the supplied word. 


CLS

INPUT "ENTER ANY WORD";A$

B$ = UCASE$(A$)

FOR I = 1 TO LEN(B$)

C$ = MID$(B$,I,1)

IF C$ = "A" OR C$ = "E" OR C$ = "I" OR C$ = "O" OR C$ = "U" THEN

D =D + 1

ELSE

E = E + 1

END IF

NEXT I

PRINT "TOTAL NUMBER OF VOWEL IS"; D

PRINT " TOTAL NUMBER OF CONSTANT IS"; E

END


4 Write a program to accept a name and display its reverse. (eg. Netra as arteN)

CLS

INPUT " ENTER YOUR NAME "; A$

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

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

NEXT I

PRINT "The Reverse of your Name is"; REV$

END



5 Write a program that accepts a string and displays whether input string is palindrome or not .

CLS

INPUT "ENTER ANY STRING"; S$

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

B$ = MID$(S$, I, 1)

W$ = W$ + B$

NEXT I

IF S$ = W$ THEN

PRINT S$; "IS PALINDROME"

ELSE

PRINT S$; "IS NOT PALINDROME"

END IF

END

6.Write a program that accepts a sentence and displays number of words in the sentence 

CLS

INPUT "ENTER ANY STRING"; S$

A = 1

FOR I = 1 TO LEN(S$)

B$ = MID$(S$, I, 1)

IF B$ = " " THEN

A = A + 1

END IF

NEXT I

PRINT "TOTAL NO. OF WORDS= "; A

END

7 .Write a program that accepts a word and display sum of ASCII codes of the each character.


8 Write a program that accept a word and change its case character by character and display the      changed word (eg. PokHaRa to pokhArA)

ClS

INPUT”ENTER ANY WORD”; W$

FOR I=1 TO LEN(W$)

C$=MID$(W$,I,1)

IF I MOD 2=0 THEN

PRINT LCASE$(C$) ;

ELSE

PRINT UCASE$(C$);

END IF

NEXT I

END


9. Write a program that accepts a word and displays a new word after removing vowels character from the word (e.g. NEPAL as NPL) 

CLS

INPUT "Enter any Name"; a$

C$ = UCASE$(a$)

For I = 1 TO LEN(C$)

b$ = MID$(C$,I,1)

If b$ < > "A" AND b$ < > "E" AND b$ < > "I" AND b$ < > "O" AND b$ < > "U" THEN

e$ = e$ + b$

END IF

NEXT I

PRINT "The Word Without Vowel is"; e$

END



10 Write a program that accepts a word and displays a new word after removing consonant characters from the word. e.g. ORANGE as OAE]

CLS

INPUT "Enter any Name"; a$

C$ = UCASE$(a$)

For I = 1 TO LEN(C$)

b$ = MID$(C$,I,1)

If b$ = "A" AND b$ = "E" AND b$ = "I" AND b$ = "O" AND b$ = "U" THEN

e$ = e$ + b$

END IF

NEXT I

PRINT "The Word Without constant is"; e$

END

11 Write a program to accept a full name of a person and display only the family Name.


12. Write a program that accepts date of birth of a person in the MM-DD-YYYY format and the +age of the person.

13 Write  program that stores system time in a variable and displays the time as 11:30 A.M.

Cls T$=TIME$ H=val( LEFT$( T$,2)) M$=MID$( T$,3,3) IF H>= 12 THEN PRINT ;H-12;M$;”PM” ELSE PRINT;H-12;M$;”AM” END IF END

 

 

14 .Write program that stores system date in a variable and displays the month in word.

CLS

a = VAL( LEFT$(DATE$,2))

SELECT CASE a

CASE 1

PRINT "current Month is January"

CASE 2

PRINT "current Month is Feburary"

CASE 3

PRINT "current Month is March"

CASE 4

PRINT "current Month is April"

CASE 5

PRINT "current Month is May"

CASE 6

PRINT "current Month is June"

CASE 7

PRINT "current Month is July"

CASE 8

PRINT "current Month is August"

CASE 9

PRINT "current Month is September"

CASE 10

PRINT "current Month is October"

CASE 11

PRINT "current Month is November"

CASE 12

PRINT "current Month is December"

CASE ELSE

PRINT "Wrong Entry"

END SELECT

END

15. Write a program to read a number and display its equivalent binary number. 

CLS

p = 1

INPUT "please enter any number="; d

WHILE d <> 0

r = d MOD 2

b = b+ p * r

p = 10 * p

d = d \ 2

WEND

PRINT " the required binary number is="; b

END

16. Write a program to read a binary number and display its equivalent decimal number.

CLS

p = 1

INPUT "please enter any number="; b

WHILE b <> 0

r = b MOD 10

d = d + p * r

p = 2 * p

b = b \ 10

WEND

PRINT " the required decimal number is="; d

END

 17   Write A Program to Display Following String pattern.


a) 


N E P A L

     E P A L

         P A L

             A L

                 L 


CLS

a$ = "NEPLA"

b = 1

FOR i = LEN(a$) to 1 STEP -1

PRINT TAB(b);RIGHT$(a$,i)

b=b+1

NEXT i

END





b)




P

E P A

N E P A L

CLS
s$ = "NEPAL"
t = 6
FOR i = 1 TO LEN(s$) STEP 2
PRINT TAB(t); MID$(s$, t, i)
t = t – 1
NEXT i
END




c)  

                                                          

N

N E

N E P

N E P A

N E P A L


CLS

A$="NEPAL"

FOR I = 1 TO LEN (A$)

PRINT LEFT$(A$,i)

NEXT i

END




d)  


L

A L

P A L

E P A L

N E P A L


CLS

A$ = "NEPAL"

FOR I = 1 TO LEN(A$)

PRINT RIGHT$(A$, I)

NEXT I

END




e)      

                                                               

N E P A L

N E P A

N E P

N E

N


CLS

a$ = "NEPLA"

b = 1

FOR i = LEN(a$) to 1 STEP -1

PRINT TAB(b);LEFT$(a$,i)

b=b+1

NEXT i

END



f)

N E P A L

E P A

P



CLS
s$ = "NEPAL"
t = 6
c=LEN(s$)
FOR i = 1 To LEN(s$)
PRINT TAB(t); MID$(s$, i,c)
t = t +1
c = c - 2
NEXT i
END