Sunday, December 16, 2012

QBASIC


Write a Program to calculate the:

1.    Area of rectangle.
Rem
Cls
Input "Enter Length "; l
Input "Enter Breadth"; b
a = l * b
Print "Area of Rectangle ="; a
End

2. Perimeter of Rectangle. Rem
Cls
 Input "Enter the Length"; l
Input "Enter the Breadth"; b
p = 2 * (l * b)
Print "perimeter of Rectangle ="; p
End

3. Area and Perimeter of Square.
Rem
Cls
Input "enter the length"; l
a = l ^ 2
Print "area of square"; a
End

Rem
Cls
Input "enter the length "; l
p=4 * l
Print "perimeter of square ="; p
End

4.     Area of Circle.
Rem
Cls
CONST Pie = 3.14
Input "enter the radius "; r
a = pie * r *2
Print "the area of circle ="; a
End


5. Circumference of circle.
Rem
Cls
CONST pie = 3.14
Input "enter the radius"; r
c = 2 * pie * r
Print "the circumference of circle ="; c
End

6.    Interest ( I = PTR/100)
Rem
Cls
Input "enter the Principle"; p
Input "enter the time"; t
Input "enter the rate"; r
i = (p * t * r) / 100
Print "interest="; i
End

7.    Volume of a cubical box.( V = l * b * h)
Rem
Cls
Input "enter the length"; l
Input "enter the breadth"; b
Input "enter the height"; h
v = l * b * h
Print "Volume of cube ="; v
End

8.    Sum, product, average and difference of two numbers.
Rem
Cls
Input "enter the first number"; a
Input "enter the second number"; b
s = a + b
p = a * b
avg = s / 2
d = a - b
Print " The sum ="; s
Print "the product ="; p
Print "the average ="; avg
Print "the difference ="; d
End

9.    Square of a given number.
 Rem
Cls
Input "enter the number "; n
s = n * n
Print "the square of number is"; s
End

10. Cube of given number.
Rem
Cls
Input "enter the number"; n
c = n * n * n
Print "cube of given number is"; c
End

11.Convert temperature given in centigrade into Fahrenheit.
             [(F = 9 * c)/5 +32]
Rem
Cls
Input "enter temperature in Centigrade"; c
f = (9 * c)/5 + 32
Print "Converted Fahrenheit ="; f
End

12.Find the greatest among two numbers.
Rem
Cls
Input "enter first number"; n1
Input "enter second number"; n2
If n1 > n2 then
Print n1;"is greatest"
Else
Print n2;"is greatest"
End if
End

13. Find the smallest among two numbers.
Rem
Cls
Input "enter first number"; n1
Input "enter second number"; n2
If n1 < n2 then
Print n1;"is smallest"
Else
Print n2;"is smallest"
End if
End

14. Find the greatest among three numbers.
Rem
Cls
Input "enter first number"; n1
Input "enter second number"; n2
Input "enter third number"; n3
If n1 > n2 then and n1 > n3
Print n1;"is greatest"
Elseif n2 > n1 and n2 > n3
Print n2;"is greatest"
Else
Print n3;"is greatest"
End if
End

15. Find the smallest among three numbers.
Rem
Cls
Input "enter first number"; n1
Input "enter second number"; n2
Input "enter third number"; n3
If n1 < n2 then and n1 < n3
Print n1;"is smallest"
Elseif n2 < n1 and n2 < n3
Print n2;"is smallest"
Else
Print n3;"is smallest"
End if
End

16.   Input ten different numbers and find the greatest.
Rem
Cls
c =1
Input "enter first number"; g
Do
Input "enter next number"; n
If n > g then
g = n
Endif
c = c + 1
If c = 10 the Exit Do
Print g;" is greatest number"
End

17. Input ten different numbers and find the smallest.
Rem
Cls
c =1
Input "enter first number"; g
Do
Input "enter next number"; n
If n < g then
g = n
Endif
c = c + 1
If c = 10 the Exit Do
Print g;" is smallest number"
End

18.Reverse the digits/number.
Rem
Cls
s = 0
Input "enter any number"; n
Do While n < > 0
r = n mod 10
s= s * 10 + r
n = n \ 10
Loop
Print "Reverse number ="; s
End

19. Find the sum of Digits.
Rem
Cls
s = 0
Input "enter digits"; n
Do While n < > 0
r = n mod 10
s = s + r
n = n \ 10
Loop
Print "The sum of digits ="; s
End

20. Find whether the given number is palindrome or not.
Rem
Cls
s = 0
Input "enter any number"; n
a = n
Do While n < > 0
r = n mod 10
s = s * 10 + r
n = n \ 10
Loop
    If a = s then
Print a; "is palindrome"
Else
Print a; "is not palindrome"
Endif
End

21. Find the sum of square of numbers.
Rem
Cls
s = 0
Input "enter the number"; n
While n < > 0
r = n mod 10
s = s + r ^ 2
n = n \ 10
Wend
Print "sum of square ="; s
End

22. Find the sum of cube of numbers.
Rem
Cls
s = 0
Input "enter the number"; n
While n < > 0
r = n mod 10
s = s + r ^ 3
n = n \ 10
Wend
Print "sum of square ="; s
End

23. Display the sum of square of numbers from 1 to 10.
Rem
Cls
s = 0
For i = 1 to 10
s = s + i ^2
Next i
Print "The sum of square of numbers from 1 to 10 ="; s
End

24. Display the sum of cube of numbers from 1 to 10.
Rem
Cls
s = 0
For i = 1 to 10
s = s + i ^3
Next i
Print "The sum of square of numbers from 1 to 10 ="; s
End

25. Find whether the given number is Armstrong or not.
Rem
Cls
s = 0
Input "enter any number "; n
a = n
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

26. Display all Armstrong numbers from 1 to 1000.
Cls
For i = 1 to 1000
s = 0
a = i
While a < > 0
r = a mod 10
s = s + r ^3
a = a \ 10
Wend
If i = s then print i
Next i
End

27. Find whether the given number is prime or composite.
Rem
Cls
Input "enter any number "; n
Flag = 0
For i = 2 to n / 2
r = n mod i
If r = 0 then
Flag = 1
Exit for
End if
Next i
If flag = 1 then
Print n;" is composite number"
Else
Print n;" is prime number"
End if
End

28. Display all prime numbers from 1 to 100.
Rem
Cls
For i = 1 to 100
Flag = 0
For j = 2 to i / 2
r = i mod j
If r = 0 then
Flag = 1
Exit for
End if
Next j
If flag = 0 then
Print i
End if
Next i
End

29. Find the factorial of a given number.
Cls
Rem
Input "enter any number"; n
f = 1
For i = 1 to n
f = f * i
Next i
Print "factorial of number ="; f
 End

30. Display the multiplication table of a given number.
Cls
Input "enter any number"; n
For i = 1 to 10
c = n * i
Print n; "x";"="; c
Next i
End

31. All natural number from 1 to 100.
Rem
Cls
For a = 1 to 100
Print a
Next a
End

32. Even numbers from 1 to 100.
Rem
Cls
For a = 2 to 100 step 2
Print a
Next a
End

33. Odd numbers from 1 to 100.
Rem
Cls
For a = 1 to 100 step 2
Print a
Next a
End

34. All natural numbers from 1 to 100 in descending order.
Rem
Cls
For a = 100 to 1 step -1
Print a
Next a
End

35. Even numbers from 1 to 100 in descending order.
Rem
For a = 100 to 1 step - 2
Print a
Next a
End

36. Odd numbers from 1 to 100 in descending order.
Rem
Cls
For a = 99 to 1 step - 2
Print a
Next a
End

37. Sum of all natural numbers from 1 to 100.
Rem
Cls
s = 0
For a = 1 to 100
s = s + a
Next a
Print "the sum of numbers ="; s
End

38. Sum of all even numbers from 1 to 100.
Rem
Cls
s = 0
For a = 2 to 100 step 2
s = s + a
Print "the sum of even numbers from 1 to 100 ="; s
Next a
End

39. Sum of all odd numbers from 1 to 100.
Rem
Cls
s = 0
For a = 1 to 100 step 2
s = s + a
Next a
Print "the sum of odd numbers from 1 to 100 ="; s
End

40. Print all natural numbers up to given number and also print its sum.
Rem
Cls
s = 0
Input "enter the range "; n
a = 1
While a < = n
s = s + a
a = a + 1
Wend
Print "All natural numbers are:"; a
Print "The sum of natural numbers ="; s
End

 42. Print even numbers up to given number and also print its sum
Rem
Cls
s = 0
Input "enter the range "; n
a = 2
While a < = n
s = s + a
a = a + 2
Wend
Print "even numbers are"; a
Print "The sum of even numbers ="; s
End

43. Print odd numbers up to given number and also print its sum.
Rem
Cls
s = 0
Input "enter the range "; n
a = 1
While a < = n
s = s + a
a = a + 2
Wend
Print "odd numbers are"; a
Print "The sum of odd numbers ="; s
End

44. Input ten different numbers and find the sum.
Cls
s = 0
For i = 1 to 10
Input "enter any ten numbers"; n
s = s + n
Next i
Print "sum ="; s
End

45. Input ten different numbers and find the sum of even numbers.
Cls
s = 0
For i = 1 to 10
Input "enter any ten numbers"; n
If n mod 2 = 0 then
s = s + n
End if
Next i
Print "The sum of even numbers ="; s
End

46. Input ten different numbers and find the sum of odd numbers.
Cls
s = 0
For i = 1 to 10
Input "enter any ten numbers"; n
If n mod 2 < > 0 then
s = s + n
End if
Next i
Print "The sum of odd numbers ="; s
End

Generate the series up to 10th term

47. 5, 25, 125......................
Rem
Cls
a = 5
For i = 1 to 10
Print a
a = a * 5
Next i
End


48. 100, 98.5, 97, 95.5....................
Rem
Cls
a = 100
For i = 1 to 10
Print a
a = a - 1.5
Next i
End

49. 0.3, 0.33, 0.333, 0.3333.......................
Rem
Cls
a = 0.3
For i = 1 to 10
Print a
a = a / 10 + 0.3
Next i
End

51. 1, 4, 9, 16...............................
Rem
Cls
For i = 1 to 10
a = i ^ 2
Print a
Next I
End

52. 1, 8, 27, 64..........................................
Rem
Cls
For i = 1 to 10
a = i ^ 3
Print a
Next i
End

53. 1, 11, 111, 1111............................ 5th term.
Rem
Cls
a = 1
For b = 1 to 5
Print a
a = a * 10 + 1
Next b
End
54. 55555, 5555, 555, 55, 5
Rem
Cls
a = 55555
For i = 1 to 5
Print a
a = (a - 5) / 10
Next i
End

55. Write to program to find the sum and the average of given data.
Data 5, 15, 20, 80, 90, 100, 70, 200, 20, 10
Rem
Cls
Dim a (10)
s = 0
For i = 1 to 10
Read a (i)
s = s + a (i)
Next i
avg = s / 10
Print "The sum of given ten numbers ="; s
Print "The Average of given the numbers ="; avg
Data 5 15 20 80 90 100 70 200 20 10
End

57. Find whether the given string is palindrome or not.
Rem
Cls
s = 0
Input "enter any number"; n
a = n
Do while n < > 0
r = n mod 10
s = s * 10 + r
n = n \ 10
Loop
If a = s then
Print a; "is palindrome number"
Else
Print a; "is not palindrome number"
End if
End

58. Count the total number of letters in a given string.
Rem
Cls
Input "enter the string "; a$
Print Len (a$)
End

new Qb


1.        WAP a program to generate series 100,98,96…….2
Ans.                                CLS
PRINT "NUMBER OF SERIES:”
PRINT
FOR E = 100 TO 2 STEP - 2
PRINT; E; “; “;
NEXT E
END
ALTERNET (Increase Order)
Ans.                        CLS
                                PRINT "NUMBER OF SERIES:"
                                PRINT
                                FOR E = 2 TO 100 STEP 2
                                PRINT; E; " , " ;
                                NEXT E
                                END
2.        WAP to print only even number from any ten numbers given by users.
Ans.                        CLS
N = 2
FOR I= 1 TO 10 STEP 1
PRINT N;
N = N + 2
NEXT I
END
3.        WAP a program to print following output.
a.       C
CO
COM
COMP
COMPU
COMPUT
COMPUTE
COMPUTER
Ans.                        CLS
                                A$ = "COMPUTER"
                                FOR I = 1 TO LEN(A$)
                                PRINT LEFT$(A$,I)
                                NEXT I
                                END
b.       1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Ans.                        CLS
                                FOR I = 6 TO 1 STEP – 1
                                FOR J = 1 TO I
`                               PRINT J;
                                NEXT
                                PRINT
                                NEXT
                                END
4.        WAP count even & odd number form following given number sets.
14,15,23,18,20,27,31,28,51,24,17,25,81,99,71,72,88,85,74
Ans.                        CLS
INPUT" ENTER  NUMBER"; N
IF N MOD 2=0 THEN
PRINT"EVEN NUMBER"
ELSE
PRINT"ODD NUMBER"
END IF
END
5.        WAP  to print prime numbers from  1 to 100
Ans.        Cls
For i = 1 to 100
Flag = 0
For j = 2 to i / 2
r = i mod j
If r = 0 then
Flag = 1
Exit for
End if
Next j
If flag = 0 then
Print I;
End if
Next i
End

6.        WAP to  calculate factorial of  any number
Ans.                                CLS
PRINT “FACTORIAL NUMBER”
                                F=1
                                INPUT “ENTER A NUMBER”;N
                                WHILE N>=1
                                F=F*N
                                N=N-1
                                WEND
                                PRINT “Factorial number is “; f
                                End
7.        WAP to calculate  tax of salary and the basis of following tax rate
Up to 5000                             10%
5001 to 10000                        12%
10001 to 15000                      14%
15001 and above 15%
Ans.                        CLS
INPUT “ENTER THE AVERAGE AMOUNT”; P
IF P>=0 AND P<=5000 THEN
D=P*.10
ELSE IF P>=5001 AND P<=10000 THEN
D=P*.12
ELSE IF P>=10001 AND P<=15000 THEN
D=P*.14
ELSE IF P>=15001 THEN
D=P*.15
END IF
V=(P-D*13/100)
T=P-D+V
PRINT “TOTAL AMOUNT IS”; T, ““
END
8.        WAP to print greatest number of among 10.
Ans.                                CLS
DIM A (10)
FOR I= 1 TO 10
INPUT A (I)
NEXT I
S= A (I)
T=A (I)
FOR I= 2 TO 10
IF A (I)>T THEN T=A (I)
NEXT I
PRINT “GREATEST NUMBER =”; T
END
9.        WAP to print ASCII value of C,O,M,P,U,T,E,R.
Ans.     CLS
INPUT “ENTER ANY CHARACTER” ; CH$
PRINT “THE ASCII VALUE OF “; CH$ “IS”; AS(CH$)
END
C=67,    O=79 ,        M=77,      P=80,      U=85,      T=84, E=69,    R=82

10.     WAP to print ASCII character of  78, 80, 90, 65, 68.
Ans.                CLS
PRINT CH$(78)               N             PRINT CH$(80)       P
PRINT CH$(90)               Z              PRINT CH$(65)       A
PRINT CH$(68)               D

new Qb


1.        WAP a program to generate series 100,98,96…….2
Ans.                                CLS
PRINT "NUMBER OF SERIES:”
PRINT
FOR E = 100 TO 2 STEP - 2
PRINT; E; “; “;
NEXT E
END
ALTERNET (Increase Order)
Ans.                        CLS
                                PRINT "NUMBER OF SERIES:"
                                PRINT
                                FOR E = 2 TO 100 STEP 2
                                PRINT; E; " , " ;
                                NEXT E
                                END
2.        WAP to print only even number from any ten numbers given by users.
Ans.                        CLS
N = 2
FOR I= 1 TO 10 STEP 1
PRINT N;
N = N + 2
NEXT I
END
3.        WAP a program to print following output.
a.       C
CO
COM
COMP
COMPU
COMPUT
COMPUTE
COMPUTER
Ans.                        CLS
                                A$ = "COMPUTER"
                                FOR I = 1 TO LEN(A$)
                                PRINT LEFT$(A$,I)
                                NEXT I
                                END
b.       1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Ans.                        CLS
                                FOR I = 6 TO 1 STEP – 1
                                FOR J = 1 TO I
`                               PRINT J;
                                NEXT
                                PRINT
                                NEXT
                                END
4.        WAP count even & odd number form following given number sets.
14,15,23,18,20,27,31,28,51,24,17,25,81,99,71,72,88,85,74
Ans.                        CLS
INPUT" ENTER  NUMBER"; N
IF N MOD 2=0 THEN
PRINT"EVEN NUMBER"
ELSE
PRINT"ODD NUMBER"
END IF
END
5.        WAP  to print prime numbers from  1 to 100
Ans.        Cls
For i = 1 to 100
Flag = 0
For j = 2 to i / 2
r = i mod j
If r = 0 then
Flag = 1
Exit for
End if
Next j
If flag = 0 then
Print I;
End if
Next i
End

6.        WAP to  calculate factorial of  any number
Ans.                                CLS
PRINT “FACTORIAL NUMBER”
                                F=1
                                INPUT “ENTER A NUMBER”;N
                                WHILE N>=1
                                F=F*N
                                N=N-1
                                WEND
                                PRINT “Factorial number is “; f
                                End
7.        WAP to calculate  tax of salary and the basis of following tax rate
Up to 5000                             10%
5001 to 10000                        12%
10001 to 15000                      14%
15001 and above 15%
Ans.                        CLS
INPUT “ENTER THE AVERAGE AMOUNT”; P
IF P>=0 AND P<=5000 THEN
D=P*.10
ELSE IF P>=5001 AND P<=10000 THEN
D=P*.12
ELSE IF P>=10001 AND P<=15000 THEN
D=P*.14
ELSE IF P>=15001 THEN
D=P*.15
END IF
V=(P-D*13/100)
T=P-D+V
PRINT “TOTAL AMOUNT IS”; T, ““
END
8.        WAP to print greatest number of among 10.
Ans.                                CLS
DIM A (10)
FOR I= 1 TO 10
INPUT A (I)
NEXT I
S= A (I)
T=A (I)
FOR I= 2 TO 10
IF A (I)>T THEN T=A (I)
NEXT I
PRINT “GREATEST NUMBER =”; T
END
9.        WAP to print ASCII value of C,O,M,P,U,T,E,R.
Ans.     CLS
INPUT “ENTER ANY CHARACTER” ; CH$
PRINT “THE ASCII VALUE OF “; CH$ “IS”; AS(CH$)
END
C=67,    O=79 ,        M=77,      P=80,      U=85,      T=84, E=69,    R=82

10.     WAP to print ASCII character of  78, 80, 90, 65, 68.
Ans.                CLS
PRINT CH$(78)               N             PRINT CH$(80)       P
PRINT CH$(90)               Z              PRINT CH$(65)       A
PRINT CH$(68)               D

Saturday, December 15, 2012

3 QB problems

# Wap to print multiplication table of any number.
cls
input"any number";n
for i= 1 to 10
print n;"x";i;"="; i*n
next i
end

# Wap to print sum of natural number up to 50
cls
s=0
x=1
do while x<=50
s= s+x
x=x+1
loop
print"sum of natural numbers up to 50";s
end


# Wap to count number of vowels in given string
cls
input c$
select case c$
case "a","e","i","o","u"
print "vowel"
case else
print "constant"
end select
end

Normal QB


1. WAP TO COUNT TOTAL NUMBER OF VOWELS IN A WORD.
CLS                                                                        
INPUT "Any word"; w$                                                        
w$ = UCASE$(w$)                                                     
FOR I = 1 TO LEN(w$)                                                
R$ = MID$(w$, I, 1)                                                
IF R$ = "A" OR R$ = "E" OR R$ = "I" OR R$ = "O" OR R$ = "U" THEN
v = v + 1
END IF
NEXT I                                                               
COLOR 5                                                                    
PRINT "Total vowel used in the word "; w$; " is  "; v                      
END
2. WAP TO CONVERT DECIMAL INTO BINARY.  
CLS
INPUT "ENTER A NUMBER"; N
WHILE N <> 0
A = N MOD 2
B$ = STR$(A)
N = N \ 2
C$ = B$ + C$
WEND
PRINT "BINARY EQUIVALENT IS"; C$
END
3.WAP TO FIND THE FACTORS OF A GIVEN NUMBER.
REM Program to print the factors of a given number
CLS
INPUT "Enter any number"; n
FOR i = 1 TO n
IF n MOD i = 0 THEN PRINT i,
NEXT i
END
4.WAP TO GENERATE FIBONACCI SERIES UPTO 10th TERM(1 1 2 3 5 8 13 21 34 55 ....).
CLS
a = 1
b = 1
FOR i = 1 TO 10
PRINT a
c = a + b
a = b
b = c
NEXT i
END



5.WAP TO FIND GREATEST AMONG THREE DIFFERENT NUMBERS.
REM Program to print greater among three different numbers
CLS
INPUT "Enter first number"; a
INPUT "Enter second number"; b
INPUT "Enter third number"; c
IF a > b AND a > c THEN
PRINT a; " is greater"
ELSEIF b > a AND b > c THEN
PRINT b; " is greater"
ELSE
PRINT c; " is greater"
END IF
END

6.WAP TO GENERATE HAILSTONE SERIES OF ANY NUMBER.
CLS
a = 7(REPLACE WITH ANY NUMBER U WANT)
FOR i = 1 TO 10
PRINT a
IF a MOD 2 = 0 THEN
a = a / 2
ELSE
a = (a * 3) + 1
END IF
NEXT i
END
7.WAP TO PRINT WHETHER THE GIVEN NUMBER IS PALINDROME OR NOT.
CLS
INPUT "ENTER A NUMBER"; N
S = N
WHILE N <> 01. WAP TO COUNT TOTAL NUMBER OF VOWELS IN A WORD.
CLS                                                                        
INPUT "Any word"; w$                                                         
w$ = UCASE$(w$)                                                    
FOR I = 1 TO LEN(w$)                                                
R$ = MID$(w$, I, 1)                                                
IF R$ = "A" OR R$ = "E" OR R$ = "I" OR R$ = "O" OR R$ = "U" THEN
v = v + 1
END IF
NEXT I                                                              
COLOR 5                                                                    
PRINT "Total vowel used in the word "; w$; " is  "; v                      
END

2. WAP TO CONVERT DECIMAL INTO BINARY.  

CLS
INPUT "ENTER A NUMBER"; N
WHILE N <> 0
A = N MOD 2
B$ = STR$(A)
N = N \ 2
C$ = B$ + C$
WEND
PRINT "BINARY EQUIVALENT IS"; C$
END
3.WAP TO FIND THE FACTORS OF A GIVEN NUMBER.
REM Program to print the factors of a given number
CLS
INPUT "Enter any number"; n
FOR i = 1 TO n
IF n MOD i = 0 THEN PRINT i,
NEXT i
END
4.WAP TO GENERATE FIBONACCI SERIES UPTO 10th TERM(1 1 2 3 5 8 13 21 34 55 ....).
CLS
a = 1
b = 1
FOR i = 1 TO 10
PRINT a
c = a + b
a = b
b = c
NEXT i
END

5.WAP TO FIND GREATEST AMONG THREE DIFFERENT NUMBERS.
REM Program to print greater among three different numbers
CLS
INPUT "Enter first number"; a
INPUT "Enter second number"; b
INPUT "Enter third number"; c
IF a > b AND a > c THEN
PRINT a; " is greater"
ELSEIF b > a AND b > c THEN
PRINT b; " is greater"
ELSE
PRINT c; " is greater"
END IF
END

6.WAP TO GENERATE HAILSTONE SERIES OF ANY NUMBER.
CLS
a = 7(REPLACE WITH ANY NUMBER U WANT)
FOR i = 1 TO 10
PRINT a
IF a MOD 2 = 0 THEN
a = a / 2
ELSE
a = (a * 3) + 1
END IF
NEXT i
END
7.WAP TO PRINT WHETHER THE GIVEN NUMBER IS PALINDROME OR NOT.
CLS
INPUT "ENTER A NUMBER"; N
S = N
WHILE N <> 0
A = N MOD 10
R = R * 10 + A
N = N \ 10
WEND
IF S = R THEN
PRINT "THE GIVEN NUMBER IS PALINDROME"
ELSE
PRINT "IT IS NOT PALINDROME"
END IF
END


8. WAP to calculate the cube root of a given number.
REM Program to calculate the cube root of a given number
CLS
INPUT “Enter any number”; n
c = n ^ (1 / 3)
PRINT “Cube root of “; n; ” is “; s
END

9. WAP to calculate the square root of a given number.
REM Program to calculate the square root of a given number
CLS
INPUT “Enter any number”; n
s = SQR(n)
PRINT “Square root of “; n; ” is “; s
END


10. Program to reverse a given string in qbasic.
CLS
INPUT “ENTER A STRING”; S$
FOR I = LEN(S$) TO 1 STEP -1
M$ = MID$(S$, I, 1)
REV$ = REV$ + M$
NEXT I
PRINT REV$
END
11. Program to reverse a given number in qbasic.
CLS
INPUT “ENTER A NUMBER”; N
WHILE N <> 0
A = N MOD 10
R = R * 10 + A
N = FIX(N / 10)
WEND
PRINT R
END
12. PROGRAM THAT PLAYS HAPPY BIRTHDAY TUNE IN QBASIC.
CLS
PLAY "L4 C8C8DCFE2 P4 C8C8DCGF2 P4"
PLAY "C8C8>C<AFED2 P4 B-8B-8AFGF2"
END
13. WAP THAT DISPLAYS A LOADING SCREEN.
CLS
COLOR 12
SLEEP 1
LOCATE 23, 35
PRINT "Loading ..."
SLEEP 1
FOR a = 2 TO 78
LOCATE 22, a
COLOR 5
PRINT "°"
NEXT a
SLEEP 1
FOR a = 2 TO 78
LOCATE 22, a
COLOR 6
PRINT "°"
FOR b = 1 TO 123333
NEXT b
NEXT a
SLEEP 2
CLS
SLEEP 1
COLOR 5
LOCATE 12, 35
PRINT "WELCOME!!!"
END
14. WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100.

CLS
A=1
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END

15. WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100.

CLS
A=2
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END

16. NUMBER PATTERN

1
11
111
1111
11111

CLS
A=1
B=1
DO WHILE B<=5
PRINT A
A= (A*10) +1
B=B+1
LOOP
END







17. WAP TO PRINT FIBONACCI SERIES.
CLS
A=2
B=2
D=1
PRINT A; B
DO WHILE D<=10
C=A+B
PRINT C
A=B
B=C
D=D+1
LOOP
END

18. SUM OF ALL EVEN NMBER FROM 1 TO 100.
CLS
A=2
B=1
WHILE B<=50
S=S+A
A=A+2
B=B+1
WEND
PRINT”THE SUM IS”; S
END
19. SUM OF ALL ODD NMBER FROM 1 TO 100.
CLS
A=1
B=1
WHILE B<=50
S=S+A
A=A+2
B=B+1
WEND
PRINT”THE SUM IS”; S
END

A = N MOD 10
R = R * 10 + A
N = N \ 10
WEND
IF S = R THEN
PRINT "THE GIVEN NUMBER IS PALINDROME"
ELSE
PRINT "IT IS NOT PALINDROME"
END IF
END


8. WAP to calculate the cube root of a given number.
REM Program to calculate the cube root of a given number
CLS
INPUT “Enter any number”; n
c = n ^ (1 / 3)
PRINT “Cube root of “; n; ” is “; s
END

9. WAP to calculate the square root of a given number.
REM Program to calculate the square root of a given number
CLS
INPUT “Enter any number”; n
s = SQR(n)
PRINT “Square root of “; n; ” is “; s
END


10. Program to reverse a given string in qbasic.
CLS
INPUT “ENTER A STRING”; S$
FOR I = LEN(S$) TO 1 STEP -1
M$ = MID$(S$, I, 1)
REV$ = REV$ + M$
NEXT I
PRINT REV$
END
11. Program to reverse a given number in qbasic.
CLS
INPUT “ENTER A NUMBER”; N
WHILE N <> 0
A = N MOD 10
R = R * 10 + A
N = FIX(N / 10)
WEND
PRINT R
END

12. PROGRAM THAT PLAYS HAPPY BIRTHDAY TUNE IN QBASIC.
CLS
PLAY "L4 C8C8DCFE2 P4 C8C8DCGF2 P4"
PLAY "C8C8>C<AFED2 P4 B-8B-8AFGF2"
END







13. WAP THAT DISPLAYS A LOADING SCREEN.

CLS
COLOR 12
SLEEP 1
LOCATE 23, 35
PRINT "Loading ..."
SLEEP 1
FOR a = 2 TO 78
LOCATE 22, a
COLOR 5
PRINT "°"
NEXT a
SLEEP 1
FOR a = 2 TO 78
LOCATE 22, a
COLOR 6
PRINT "°"
FOR b = 1 TO 123333
NEXT b
NEXT a
SLEEP 2
CLS
SLEEP 1
COLOR 5
LOCATE 12, 35
PRINT "WELCOME!!!"
END
14. WAP TO PRINT ALL ODD NUMBER FROM 1 TO 100.
CLS
A=1
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END
15. WAP TO PRINT ALL EVEN NUMBERS FROM 1 TO 100.
CLS
A=2
B=1
DO WHILE B<=50
PRINT A
A=A+2
B=B+1
LOOP
END

16. NUMBER PATTERN
1
11
111
1111
11111
CLS
A=1
B=1
DO WHILE B<=5
PRINT A
A= (A*10) +1
B=B+1
LOOP
END
17. WAP TO PRINT FIBONACCI SERIES.
CLS
A=2
B=2
D=1
PRINT A; B
DO WHILE D<=10
C=A+B
PRINT C
A=B
B=C
D=D+1
LOOP
END
18. SUM OF ALL EVEN NUMBER FROM 1 TO 100.
CLS
A=2
B=1
WHILE B<=50
S=S+A
A=A+2
B=B+1
WEND
PRINT”THE SUM IS”; S
END
19. SUM OF ALL ODD NUMBER FROM 1 TO 100.
CLS
A=1
B=1
WHILE B<=50
S=S+A
A=A+2B=B+1
WEND
PRINT”THE SUM IS”; S
END