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 Function | User Defined Functions |
|
|
|
|
|
|
|
|
Example : SIN, COS, Power | Example : 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.
0 Comments