1
2
3
4
5
Program:
Sub Test()
Dim i As Integer
Dim j As Integer
For i = 1 To 5
For j = 1 To i
If i = j Then
Debug.Print j;
Debug.Print Chr(10);
End If
Debug.Print " ";
Next j
Next i
End Sub
2. Program to print the following series.
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Sub Test()
Dim i As Integer
Dim j As Integer
For i = 1 To 5
For j = 1 To 5
If j <= i Then
Debug.Print j;
End If
Next j
Debug.Print Chr(10);
Next i
End Sub
3. program to print the following:
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
Program:
Sub Test()
Dim i As Integer
Dim j As Integer
For i = 5 To 1 Step -1
For j = 5 To 1 Step -1
If j >= i Then
Debug.Print j;
End If
Next j
Debug.Print Chr(10);
Next i
End Sub
4. program to print the following
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
Program:
Sub Test()
Dim i As Integer
Dim j As Integer
For i = 5 To 1 Step -1
For j = 5 To 1 Step -1
If j <= i Then
Debug.Print j;
End If
Next j
Debug.Print Chr(10);
Next i
End Sub
5. Program to print the following series.
54321
4321
321
21
1
Program:
Sub Test()
Dim i As Integer
Dim j As Integer
For i = 5 To 1 Step -1
For j = 5 To 1 Step -1
If j > i Then
Debug.Print " ";
Else
Debug.Print Trim(j);
End If
Next j
Debug.Print Chr(10);
Next i
End Sub
6. Write a program for the following Series.
1
121
12321
1234321
123454321
Program:
Sub test()
Dim i As Integer
Dim j As Integer
Dim a As Integer
For a = 1 To 5
For i = 1 To a
Debug.Print Trim(i);
Next i
If i = a + 1 Then
For j = a - 1 To 1 Step -1
Debug.Print Trim(j);
Next j
End If
Debug.Print Chr(10);
Next a
End Sub
7. Program to print the following series
1
121
12321
1234321
123454321
Program:
Sub test()
Dim i As Integer
Dim j As Integer
Dim a As Integer
Dim c As Integer
For a = 1 To 5
For i = 1 To a
If i = 1 Then
For b = (5 - a) To 1 Step -1
Debug.Print (" ");
Next b
End If
Debug.Print Trim(i);
Next i
If i = a + 1 Then
For j = a - 1 To 1 Step -1
Debug.Print Trim(j);
Next j
End If
Debug.Print Chr(10);
Next a
End Sub
1
121
12321
1234321
123454321
Program:
Sub test()
Dim max As Integer
max = 5
Dim i As Integer
Dim j As Integer
For a = 1 To max
Debug.Print Space(max - a);
For i = 1 To a * 2 - 1
If i <= a Then
Debug.Print Trim(i);
Else
j = i - a
Debug.Print Trim(a - j);
End If
Next i
Debug.Print Chr(10);
Next a
End Sub
9. Program to find the following output.
* *
* *
*
* *
* *
Program:
Sub test()
Dim i As Integer
Dim j As Integer
For i = 1 To 5
For j = 1 To 5
If i = j Or i + j = 6 Then
Debug.Print "*";
Else
Debug.Print " ";
End If
Debug.Print " ";
Next j
Debug.Print Chr(10);
Next i
End Sub
Program:
Sub Test()
Dim n As Integer
Dim i As Integer
Dim sum As Integer
sum = 1
n = InputBox("Please enter the number")
For i = n To 1 Step -1
sum = sum * i
Next i
Debug.Print sum;
End Sub
No comments:
Post a Comment