Question collections of SUB Procedure

1.      Write a program to input base and height of the triangle from user. The program should calculate and display the area of the triangle using SUBEND SUB statement.
2.      Write a Sub program to print area of cylinder, if radius and height of cylinder are given by the user in main module and pass them as parameter list when Sub program is called.
3.      Write a sub procedure to find the solution of quadratic equation ax2+bx+c=0. The program should ask the value a, b and c from user in main module and pass them as parameter list when a Sub Program is called.
4.       Write a Sub Program to display the acceleration of car. The program should ask initial velocity, final velocity and time taken by the car from user in main module and pass them as parameter list when a Sub Program is called.
5.      Write a Sub Program to check whether an input number is “Positive” or “Negative” or “Zero”. The program should ask a number from user in main module and passes it as parameter list when a program is called.
6.      Write a program to decide whether an input number is even or odd. The program should ask a number from user in main module and pass them as parameter list.
7.      Write a program to declare a sub procedure module to decide whether a triangle can be formed or not if three sides of a triangle are keyed by the user.
8.      Write a sub program to print first 10 natural numbers followed by its square and cubes.
9.      Write a Sub Program using SUB-END SUB statement to calculate and display the geometric series. The program should ask first term, common ratio and numbers of terms in main module and call the Sub Program to get the result.
10.  Write a sub procedure to display the sum of first 20 even numbers.
11.  Write a sub procedure to display the sum of first 30 odd numbers.
12.  Write a sub procedure to display the numbers which are multiples of 5 and 6 from 5 to 100.
13.  Write a sub program to decide whether an input year is leap year or not.
14.  Write a program to input a number and check whether the number is Armstrong or not using SUB-END. SUB.
15.  Write a program to input a number and check whether the number is prime or not using SUB-END SUB.  
16.  Write a sub procedure program using SUB-END SUB statement to display the prime numbers from 2 to 100.
17.  Write a sub procedure program using SUB-END SUB statement to find sum from 1 to given number. For example: sum=1+2+3+…+N
18.  Write a sub program using SUB-END SUB statement to display factorial of an input number. Note: The product from 1 to given number is called factorial of number. For example: The factorial of 5 is 120. That is 1120
19.  Write a sub program using SUB-END SUB statement to check whether input string is palindrome or not. For example: LIRIL is a palindrome because the word pronounced same from forward and backward.
20.  Write a sub program to check whether an input character is alphabet or digit or symbol. The program should ask a character from user in main module and pass it as parameter list when a sub program is called.
21.  Using SUB-END SUB statement write a program to calculate the area of a circle where radius is given from keyboard.
22.  Write a program to generate the HAIL STONE series using SUB-END SUB statement. Hail stone series is that first series can be any positive number. Second series is obtained as follows, if the first number is even divide by 2 and id the first number is odd multiply by 3 and add 1 to the numbers so the final value should be 1.
23.  Write a sub procedure to input a number and display the multiplication table of the same number up to 10 terms.
24.  Write a SUB-END SUB program to display the following pattern:
KATHMANDU
ATHMAND
THMAN
HMA
M
25.  Write a SUB program to display the following series 1,3,9,27,81,…….up to 10th terms.
26.  Write a program to declare a sub procedure using SUB-END SUB statement to display factors of an input number.
27.  Write the output of the given program.
a.       DECLARE SUB Result()
CALL Result
END
SUB Result()
V=5
C=1
WHILE C<=5
PRINT V,V^C
WEND
END SUB
b.      DECLARE SUB Series()
CLS
CALL Series
END
SUB Series()
X=9
FOR C=1 TO 10
PRINT X;
IF X MOD 2=0 THEN
X=X/2
ELSE
X=3*X+1
END IF
NEXT C
END SUB
c.       DECLARE SUB PICTURE(ST$)
CLS
X$=”SCIENCE”
CALL PICTURE(X$)
END
SUB PICTURE(ST$)
T=20
P=4
N=1
FOR A=1 TO 4 STEP 1
PRINT TAB(T);MID$(ST$,P,N)
P=P-1
N=N+2
T=T-1
NEXT A
END SUB
d.      DECLARE SUB L(A$,B$,C$)
CLS
FOR A%= 1 TO 3
READ X$,Y$,Z$
CALL (X$,Y$,Z$)
NEXT A%
DATA “NEEMA”,”JAY”,”SAHAN”,”PRABHA”,”KARN”,”MUKUNDA” ,”RAM”,”CHANDRA”,”KARKI”
END
SUB L(A$,B$,C$)
A=LEN(A$)
B=LEN(B$)
C=LEN(C$)
IF A<B AND A<C THEN H$=A$
IF B<A AND B<C THEN H$=B$
IF C<A AND C<B THEN H$=C$
PRINT H$
END SUB



Comments

Jiwan Subedi said…
mathi kaa sabai ko solution xaina ta sir jee !!
Unknown said…
Write a program to input base and height of the triangle from user. The program should calculate and display the area of the triangle using SUB END SUB statement.


declare sub area(b,h)
Cls
Input "Enter Base of triangle:"; b
Input "Enter height of a triangle:"; h
Call area(b, h)
End
Sub area (b, h)
a = 0.5 * b * h
Print "Area is "; a
End Sub

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PALINDROME AND ARMSTRONG PROGRAMS

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS