Top Banner

of 24

projct 3&4

Apr 07, 2018

Download

Documents

Nitin Grover
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/3/2019 projct 3&4

    1/24

    ASSIGNMENT-3

    Q1> Write a program to print first 50 natural numbers?

    Sol>

    Private sub command1_click()

    Dim i as integer

    For i = 1 to 50

    Print i

    Next i

    End sub

  • 8/3/2019 projct 3&4

    2/24

    Q2> Write a program to print all even numbers between( 1-50)?

    Ans>

    Private sub command1_click()

    Dim i as integer

    For i = 0 to 50 Step 2

    Print i

    Next i

    End sub

  • 8/3/2019 projct 3&4

    3/24

    Q3> Write a program to print first 10 natural numbers in reverse order?

    Sol>

    Private sub command1_click()

    Dim i as integer

    For i = 10 to 1 step -1

    Print i

    Next i

    End sub

  • 8/3/2019 projct 3&4

    4/24

    Q4> Write a program to enter any number from the user. Print its first 10 multiplies?

    Sol>

    Private sub command1_click()

    Dim i as integer

    Dim m as integer

    i = text1.text

    for m = 1 to 10

    print m*i

    next m

    end sub

  • 8/3/2019 projct 3&4

    5/24

    Q>5 Write a program to print the sum of first 10 natural numbers?

    Sol>

    Private sub command1_click()

    Dim i as integer

    Dim sum as integer

    Sum = 0

    For i = 1 to 10

    Sum = i + sum

    Next i

    Print sum

    End sub

  • 8/3/2019 projct 3&4

    6/24

    Q6> Write a program to print the product of first 10 natural numbers?

    Sol>

    Private sub command1_click()

    Dim i as integer

    Dim product as long

    Product = 1

    For i = 1 to 10

    Product= product* i

    Next i

    Print product

    End sub

  • 8/3/2019 projct 3&4

    7/24

    Q7> Write a program to enter any number from the user and display its factorial in another

    textbox?

    SOL>

    Private sub command1_click()

    Dim fact as integer

    Dim i as integer

    Dim num as integer

    Num= text1.text

    For i = 1 to num

    Fact= i* fact

    Next i

    Text2.text= fact

    End sub

  • 8/3/2019 projct 3&4

    8/24

    Q8> Write a program to find out whether the number is odd or even?

    Sol>

    Private sub commad1_click()

    Dim i as integer

    i = text1.text

    if i mod 2 = 0 then

    msgbox(even number)

    else

    msgbox(odd number)

    end if

    end sub

  • 8/3/2019 projct 3&4

    9/24

    Q9> print the sum of the following series if the value of x and n are input from user?

    Sol>

    Private sub command1_click()

    Dim x As Integer

    Dim n As Integer

    Dim sum As Double

    x = Val(Text1.Text)

    n = Val(Text2.Text)

    sum = 0

    For i = 0 To n

    sum = sum + (1 / (x ^ i))

    Next i

    Text3.Text = sum

    End sub

  • 8/3/2019 projct 3&4

    10/24

    Q10> Write a program to show the usage of static variables?

    Sol>

    Private sub command1_click()

    Call example

    End sub

    Sub example()

    Static istatic as integer

    istatic = istatic+1

    print istatic

    end sub

  • 8/3/2019 projct 3&4

    11/24

    Assignment-4

    Q1> Let the user input number of terms. Write a function to print fabonacii series?

    Sol>

    private sub command1_click()

    call fabonacci_series()

    end sub()

    function fabonacci_series()

    dim num as integer

    dim a as integer

    dim b as integer

    dim c as integer

    dim i as integer

    num = text1.text

    a = 0

    b = 1

    print a

    print b

    for i = 1 to num-2

    c = a + b

    print c

    a = b

    b = c

    next i

    end function

  • 8/3/2019 projct 3&4

    12/24

    Q2> Write a program to find out the total salary including HRA, city allwance, Vehicle

    allowance?

    Sol>

    Private sub command1_click()

    Text3.text= (59/100)*text2.text

    Text4.text= 800

    If check1.value= 1 then

    Text5.text=0

    Else

    Text5.text=800

    End if

    Text6.text= val(text3.text) + val( text4.text) + val(text5.text)

    End sub

  • 8/3/2019 projct 3&4

    13/24

  • 8/3/2019 projct 3&4

    14/24

    Q3> Write a function to find out whether the number input by the user is prime number or not?

    Sol>

    Private Sub Command1_Click()

    Dim i, x As Integer

    Dim flag As Boolean

    flag = False

    x = Val(Text1.Text)

    For i = 2 To x - 1

    If (x Mod i = 0) Then

    flag = True

    End If

    Next

    If flag = True Then

    Print "not prime"

    Else

    Print "prime no."

    End If

    End Sub

  • 8/3/2019 projct 3&4

    15/24

  • 8/3/2019 projct 3&4

    16/24

    Q4> Write a program to enter different number from the user until the user enters zero?

    Sol>

    Private sub command1_click()

    Dim num as integer

    Dim sum as integer

    Sum=0

    Do

    Num = inputbox(enter number, number entry form)

    Sum= sum +num

    Print sum

    Loop while num0

    End sub

  • 8/3/2019 projct 3&4

    17/24

    Q5> write a program to enter a name and age by the user. If the age lies between(18 to 40 yrs),

    display in the message boxYou are elgible for the interview, otherwise display you are not

    eligible for interview.

    Sol>

    Private Sub Command1_Click()

    Dim I As Integer

    I = Text2.Text

    If I >= 18 And I < 40 Then

    MsgBox ("YOU ARE ELIGIBLE FOR INTERVIEW")

    Else

    MsgBox ("YOU ARE NOT ELIGIBLE FOR INTERVIEW")

    End If

    End Sub

  • 8/3/2019 projct 3&4

    18/24

  • 8/3/2019 projct 3&4

    19/24

  • 8/3/2019 projct 3&4

    20/24

  • 8/3/2019 projct 3&4

    21/24

  • 8/3/2019 projct 3&4

    22/24

  • 8/3/2019 projct 3&4

    23/24

  • 8/3/2019 projct 3&4

    24/24