Thought Sharing

Wednesday, September 28, 2011

Display first n elements of Fibonacci series in VB

Private Sub Command1_Click()
Dim x, y, n, i, sum As Integer
n = Val(Text1.Text)
x = 0
y = 1
Print x
Print y
For i = 3 To n
sum = x + y
Print sum
x = y
y = sum
Next i
End Sub

Program to calculate Factorial of a number in VB 6.0

Private Sub Command1_Click()

Dim n As Integer
Dim fact As Integer
fact = 1
n = Val(Text1.Text)
For i = 1 To n
fact = fact * i
Next
MsgBox "factorial of " & n & " is = " & fact

End Sub

Thursday, April 28, 2011

Swaping Two Numbers using third variable (VB 6.0)

Write a program in VB 6.0 to Swap Two Numbers using third variable

Private Sub Command1_Click ()
Dim a As Integer
Dim b As Integer
Dim temp As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
temp = b
b = a
a = temp
Text1.Text = a
Text2.Text = b
End Sub

Sunday, April 24, 2011

List of Programs for OOPs Practical File

List of Programs for OOPs Practical File

1. WAP to find the sum of two numbers using function.
2. WAP to find Simple Interest and Compound Interest.
3. WAP to demonstrate the working of following Loops:
While, Do While, For,If-Else, Switch.
4. WAP to find greatest of three numbers.
5. WAP to check whether a number is even or odd.
6. WAP to check whether a year is leap year or not.
7. WAP to add and subtract two matrices.
8. WAP to display elements of an array.
9. WAP to calculate Sum and Average of an array.
10. WAP to sort elements of an array using Bubble sort.
11. WAP to calculate Factorial of a number.
12. WAP to check whether a given number is Prime or not.
13. WAP to generate Fibonacci series.
14. WAP to show function Overloading.
15. WAP to create a class and access member function of a class.

Friday, February 25, 2011

Sum and Averaage of elements of Array in C++

Write a program to find Sum and Average of elements of Array

#include
#include

void main()
{
int n ,a[20],sum=0,avg;
clrscr();
cout<<"enter size of array: ";
cin>>n;
cout<<"Enter elements of Array: ";
for(int i=0;i{
cin>>a[i];
}
cout<<"sum of elements of array: ";
for(i=0;i{
sum=sum+a[i];
}
cout<cout<<"Average of array elements is: ";
avg=sum/n;
cout<getch();
}

FACTORIALS OF A NUMBER IN C++

Write a program to find Factorials of a number

#include
#include
void main()
{
clrscr();
int n, fact=1;
cout<<"Enter the number: ";
cin>>n;
for ( int i=1; i<=n; i++)
{
fact= fact * i;
cout<}
cout<<"Factorial of this number is: ";
cout<getch();
}