Recent Post

Wednesday, 20 August 2025

Chapter 5: Programming in Visual Studio - Answer and Questions

Chapter 5: Programming in Visual Studio | Computer 8th By Pratap Sanjay Sir Computer Notes
By Pratap Sanjay Sir

Chapter 5: Programming in Visual Studio – EVALUATION SHEET

I. Tick (✔) the correct option:

  1. A ______ is a value that can be recorded in the application's memory temporarily.
    a. keyword
    b. variable
    c. operand
  2. Which data type is used to store either True or False value?
    a. Char
    b. Long
    c. Boolean
  3. Which of the following is both an arithmetic and string operator?
    a. /
    b. &
    c. +
  4. The ______ statement can be used in place of the If ... Then ... ElseIf statement?
    a. For ... Next
    b. Select ... Case
    c. While ... End
  5. Which event of a RadioButton control occurs when the value of the Checked property changes?
    a. CheckedChanged
    b. Click
    c. AppearanceChanged

II. Fill in the blanks with the suitable words:

  1. The Val() function is used for extracting numeric value from the controls inserted in the form.
  2. A variable is a value that can be recorded in the application's memory temporarily.
  3. The property of a variable which defines its characteristics is known as Data type.
  4. The statement in which you declare a variable informs the compiler about the data type of the variable.
  5. The Do ... Loop Until statement first executes the statements and then tests the condition after each execution.

III. Write 'T' for True and 'F' for False statements:

  1. A variable can be longer than 255 characters. (F)
  2. The declaration of a variable does not store any data in it. (T)
  3. It is not mandatory to declare a variable in Visual Basic. (T)
  4. Relational operators are used to compare two different operands in a program. (T)
  5. For ... Next statement is used to execute a set of statements for a specific number of times. (T)

IV. Answer the following questions:

1. What is the difference between implicit and explicit declaration of a variable?

Implicit declaration: Variable is used without declaring (possible if Option Explicit is OFF).
Explicit declaration: Variable is defined using Dim keyword with data type.

' Explicit Declaration
Dim x As Integer
x = 10

' Implicit Declaration (not recommended)
y = 20
  

2. State the rules you should keep in mind while naming variables in a program.

- Must begin with a letter.
- Can contain letters, numbers, underscore (_).
- Cannot contain spaces or special characters.
- Should not be a reserved keyword.
- Must be meaningful.

3. Name the common data types provided in VB.

Integer, Long, Single, Double, String, Boolean, Date, Currency, Object.

Dim rollNo As Integer
Dim marks As Double
Dim name As String
Dim isPassed As Boolean
  

4. Write a short note on Control Statements in Visual Basic.

Control statements manage the execution flow of a program:
- **Decision making:** If...Else, Select Case
- **Looping:** For...Next, While...End, Do...Loop
- **Jumping:** Exit, Continue

Dim i As Integer
For i = 1 To 5
    MsgBox("Iteration: " & i)
Next i
  

5. What is nesting? Give the syntax of a nested If ... Then ... Else statement.

Nesting: Using one control structure inside another.

If age >= 18 Then
    If age >= 60 Then
        MsgBox("Senior Citizen")
    Else
        MsgBox("Adult")
    End If
Else
    MsgBox("Minor")
End If
  

6. Write a sample program to explain the use of string operator "&".

Dim fname As String, lname As String
fname = "Pratap"
lname = "Sir"
MsgBox("Welcome " & fname & " " & lname)
'Output: Welcome Pratap Sir
  

V. Define the following terms:

  1. Data type: Defines the type of data a variable can store (e.g., Integer, String, Boolean).
  2. Operands: Values or variables on which operators perform operations.
  3. Inversion: Logical NOT operation (~ or Not) which reverses Boolean value.
    Dim flag As Boolean
    flag = True
    MsgBox(Not flag)  ' Output: False
          
  4. Relational operators: Operators used to compare two values (=, <, >, <=, >=, <>).
    If 10 > 5 Then
        MsgBox("10 is greater")
    End If
          
  5. Iteration: Repeated execution of statements until condition is met (looping).
    Dim i As Integer
    i = 1
    Do While i <= 5
        MsgBox("Count: " & i)
        i = i + 1
    Loop
          
🔔 Subscribe to My Channel

No comments:

"कोशिश करो तो सब कुछ हो सकता है, न करो तो कुछ नहीं हो सकता।"