Practical 1:
Sorting an array of integers using Bubble Sort method
Algorithm:
Input: An array of integers
Output: Sorted array of integers in ascending order
Steps:
1. Start
2. Take any ‘n’ numbers from the user into an array
3. for (n-1) passes
4. for all elements of the unsorted array
a. if array[j] > array[j+1]
b. swap(array[j], array[j+1])
c. end if
5. end for
6. end for
7. Display the sorted array to the user
8. Stop
Function swap(int x,int y)
1. Start
2. Exchange the data using temporary variable
3. Stop
FlowChart:
Start
Take ‘n’ numbers
from the user into
an array
Pass
number=1
Is pass Yes
Display the
number sorted array
> (n-1)
No
Increment j=0
pass number
Stop
Yes Is j > (n-
pass
number)
Yes No
Is No
a[j]>a[j+1] J++
Swap a[j]
and a[j+1]
/*Bubble Sort*/
#include<iostream.h>
#include<conio.h>
void main()
{
int a[10],i,j,k,t;
clrscr();
cout<<"Enter 10 Numbers to sort :";
for(i=0;i<10;i++)
cin>>a[i];
cout<<"Array Elements :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
for(k=1;k<10;k++)
{
for(j=0;j<10-k;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
cout<<"Sorted Array :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
getch();
}
OUTPUT:
Practical 2:
Exchanging data of two integers using pointers
Algorithm:
Input: 2 numbers
Output: Data of the 2 numbers exchanged
Steps:
1. Start
2. Take 2 numbers from the user
3. Display the numbers before swapping
4. Call the function ‘swap’ with the address of the 2 numbers being sent as
parameters(Call by reference)
5. Display the numbers after swapping
6. Stop
Function swap(&first, &second)
1. Start
2. Receive the 2 numbers using pointers
3. Exchange the data using temporary variable
4. Stop
FlowChart:
/*Swap two numbers using pointers*/
#include<iostream.h>
#include<conio.h>
void swap(int *,int *);
void main()
{
int n1,n2;
clrscr();
cout<<"Enter Number 1 :";
cin>>n1;
cout<<"Enter Number 2 :";
cin>>n2;
cout<<"Numbers before swapping :"<<n1<<"\t"<<n2<<endl;
swap(&n1,&n2);
cout<<"Numbers after swapping :"<<n1<<"\t"<<n2<<endl;
getch();
}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
OUTPUT:
Practical 3:
Searching a number in an array using Binary Search Technique
Algorithm:
Input: Array of numbers and the number to be searched
Output: If the number is found its’ position is displayed; else “number not found” is displayed.
Steps:
1. Start
2. Take any n numbers from the user into an array and the number to be searched.
3. Sort the numbers using Bubble_Sort technique
4. Call the function Binary_Search with array and the search element being passed as
parameters
5. Receive the result of search
6. If the result is -1; then display that the search element is not found in the array
7. Else display the position of the search element
8. Stop
Position of search element = Binary_Search(array, search element)
1. Start
2. Assign low to the first position of the array (low=0)
3. Assign high to the last position of the array (high=n-1)
4. Up: If low <=high (termination condition for the binary search)
i. mid= (low+high)/2 (Calculate the mid position of the array)
ii. If search element is equal to the mid element
iii. Search element found. Return mid
iv. If search element < mid element
v. Search in the lower half of the array
vi. High=mid-1
vii. Else
viii. Search in the upper half of the array
ix. Low=mid+1
x. Go to Up
5. Search element not found if low<=high. Return -1
6. Stop
FlowChart:
START
Input 10 Array
elements
Input Number to
be searched as key
Call Bsearch function
Yes
If loc=-1 Print search
element not found
No
Print position of
search element
STOP
Bsearch () function
START
Initialize low=0,
high=arraysize-1
No
If Return -1 to main
low<=high Function
Yes
Mid=(low+high)/2
Yes
If search= Return mid to main
array[mid] Function
No
No
If search<
Low=mid+1
array[mid]
Yes
High=mid-1
/*Binary Search*/
#include<iostream.h>
#include<conio.h>
int binsearch(int [],int); //function prototype
void main()
{
int a[10],i,j,k,t,s,loc;
clrscr();
cout<<"Enter 10 array elements:"<<endl;
for(i=0;i<10;i++)
cin>>a[i];
cout<<"Array Elements :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
for(k=1;k<10;k++)
{
for(j=0;j<10-k;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
cout<<"Sorted Array :"<<endl;
for(i=0;i<10;i++)
cout<<a[i]<<"\t";
cout<<"Enter Number to search :";
cin>>s;
loc=binsearch(a,s);
if(loc==-1)
cout<<"Number not found";
else
cout<<"Number found at position :"<<loc+1;
getch();
}
int binsearch(int a[],int no)
{
int low=0,mid,high=9;
while(low<=high)
{
mid=(low+high)/2;
if(no==a[mid])
return mid;
if(no<a[mid])
high=mid-1;
else
low=mid+1;
}
return -1;
}
OUTPUT:
Practical 4:
Implementing Class Ratio with member functions like assign, convert and
invert.
Algorithm:
Input: No input given by user
Output: Result of the ratio converted in decimal format is displayed
Inverted ratio is displayed
Steps:
1. Start
2. Create the class ratio with member functions - assign, convert, invert, print and member
data - numerator and denominator
3. Create an object of class ratio.
4. Invoke Assign function
5. Call Convert function
6. Call Invert function
7. Call print function
8. Stop
Assign(int n, int d)
1. Start
2. numerator =n
3. denominator.=d
4. Stop
Convert()
1. Start
2. Return (double)num/den;
3. Stop
Invert()
1. Start
2. Exchange the numerator and denominator of the ratio
3. Stop
Print()
1. Start
2. Print the numerator and denominator
3. Stop
Flowchart:
START
Define Class Ratio
with member functions
assign, convert, invert and
print
Create an object of class
ratio
Call assign()
Call print()
Call convert()
Call invert()
Call print()
STOP
assign(n,d) convert()
START START
numerator=n return
(double)num/den;
denominator=d
STOP STOP
invert() print()
START START
set temp=num;
Display the numerator and
num=den; denominator of ratio
den=temp;
STOP STOP
/*Implementing class ratio with member functions like assign, convert and invert */
#include<iostream.h>
#include<conio.h>
class ratio
{
public:
void assign(int, int);
double convert();
void invert();
void print();
private:
int num, den;
};
void main()
{
ratio x;
x.assign(22,7);
clrscr();
cout<<"x=";
x.print();
cout<<"="<<x.convert()<<"\n";
x.invert();
cout<<"1/x=";
x.print();
cout<<"\n";
getch();
}
void ratio::assign(int numerator, int denominator)
{
num=numerator;
den=denominator;
}
double ratio::convert()
{
return (double)num/den;
}
void ratio::invert()
{
int temp=num;
num=den;
den=temp;
}
void ratio::print()
{
cout<<num<<"/"<<den;
}
OUTPUT:
Practical 5:
Implementing Class Circle with default constructor and accessing functions like
area and circumference.
Algorithm:
Input: Radius of Circle
Output: Area and Circumference of circle displayed
Steps:
1. Start
2. Define a class ‘circle’ with rad,x,y as data members, a default constructor to initialize
rad,x,y to 0.and member functions – getdata(),area(),circumference().
3. Create an object of class ‘circle’
4. Invoke getdata(), area(), circumference for the object and display the respective
results
5. Stop
Assign(int n, int d)
1. Start
2. numerator =n
3. denominator.=d
4. Stop
getdata()
1. Start
2. input x and y coordinates of the center point
3. input radius
4. Stop
area()
1. Start
2. ar=3.14*rad*rad
3. print ar as area of circle
4. Stop
circumference()
1. Start
2. print 2*3.14*rad as circumference
3. Stop
FlowChart:
START
Define a class ‘circle’ with rad,x,y as data
members, a default constructor to initialize
rad,x,y to 0.and member functions –
getdata(),area(),circumference().
Create an object of class
circle
Call getdata()
Call area()
Call circumeference()
STOP
getdata() area()
START START
ar=3.14*rad*rad
Input x,y,rad
Print ar
STOP
STOP
circumference()
START
Print 2*3.14*rad as
circumference
STOP
/* Implementing class circle with default constructor and accessing member functions like area and
circumference */
#include<iostream.h>
#include<conio.h>
class circle
{
private:
float rad,x,y;
public:
circle() //default constructor
{
rad=0;
x=0;
y=0;
}
void getdata()
{
cout<<"Enter x-coord and y-coord of center point :";
cin>>x>>y;
cout<<"Enter radius :";
cin>>rad;
}
void area()
{
float ar;
ar=3.14*rad*rad;
cout<<"Area :"<<ar<<endl;
}
void circumference()
{
cout<<"Circumference :"<<2*3.14*rad<<endl;
}
};
void main()
{
clrscr();
circle o;
o.getdata();
o.area();
o.circumference();
getch();
}
OUTPUT:
Practical 6:
Study scope of an object using constructor and destructor.
Algorithm:
Input: No input given by user
Output: The output of constructor and destructor is displayed. Scope of constructor and
destructor is seen.
Steps:
1. Start
2. Create class Ratio with constructor and destructor and print() function
3. Create an object of class ratio
4. Call print()
5. Stop
print() function
1. Start
2. Print that the object is alive
3. Stop
Constructor ratio()
1. Start
2. Print that the object is born
3. Stop
Destructor ~ratio()
1. Start
2. Print that the object is dead
3. Stop
FlowChart:
START
Define a class ‘ratio’ with constructor,
destructor and member function print()
Create an object of class
ratio
Call print()
STOP
Constructor ratio() Destructor ~ratio()
START START
Print “Object is born” Print “Object is dead”
STOP STOP
print()
START
Print “Object is Alive”
STOP
/*Scope of constructor and destructor */
#include<iostream.h>
#include<conio.h>
class Ratio
{
public:
void print()
{
cout<<"\nNow X is ALIVE"<<endl;
}
Ratio()
{
cout<<"OBJECT IS BORN"<<endl;
}
~Ratio()
{
cout<<"OBJECT DIES";
}
};
void main()
{
clrscr();
Ratio r1;
r1.print();
getch();
}
Output:
Practical 7:
Overloading + and / operator.
Algorithm:
Input: Numerator and denominator of 2 ratios are taken from user
Output: The result of addition and division of the 2 ratios are displayed to the user
Steps:
1. Start
2. Create class Ratio with data members - numerator and denominator
3. Define member functions get() and show()
4. Overload the operators ‘+’ and ‘/’ to work on ratio data type
5. Declare 3 objects of the class Ratio
6. Get ratio 1 and ratio 2 from the user
7. Perform ratio 1+ratio 2 using overloaded operator ‘+’; store the result in the 3 rd ratio
and display the result to the user
8. Perform ratio 1/ratio 2 using overloaded operator ‘/’; store the result in the 3rd ratio and
display the result to the user
9. Stop
get()
1. Take the numerator and denominator of the ratio
show()
1. Display the numerator and denominator of the ratio
Overloaded operator ‘+’
1. If the denominators are the same add the numerators
2. If the denominators are not the same then L.C.M. is taken and addition is performed
Overloaded operator ‘/’
1. The result is the ratio 1 multiplied with the reciprocal of the ratio 2.
FlowChart:
START
Define a class ‘ratio’ with data members
numerator and denominator
Define member functions
get() and show()
Overload the operators ‘+’ and
‘/’ to work on ratio data type
Declare 3 objects of the
class Ratio
r1.get()
r2.get()
r3=r1+r2
r3.show()
A
A
r3=r1/r2
r3.show()
STOP
get() show()
START START
Get the numerator and
Print the numerator
denominator
and denominator
STOP STOP
Overloaded ‘+’ () Overloaded ‘/’()
START START
r3.num=num1*den2
No
Is r3.den=den1*num2
den1==
den2
Yes Return r3
r3.num=num1+num2
STOP
Take the L.C.M. of r1
and r2 to perform
r3=r1+r2
Return r3
STOP
/* Overloading + and / operator */
#include<iostream.h>
#include<conio.h>
class Ratio
{
int num,den;
public:
void get()
{
cin>>num>>den;
}
void show()
{
cout<<num<<"/"<<den<<endl;
}
Ratio operator +(Ratio r)
{
//o1.operator(o2)
Ratio t;
if(den==r.den)
{
t.num=num+r.num;
t.den=den;
}
else
{
t.num=num*r.den+r.num*den;
t.den=den*r.den;
}
return t;
}
Ratio operator /(Ratio r)
{
Ratio t;
t.num=num*r.den;
t.den=den*r.num;
return t;
}
};
void main()
{
clrscr();
Ratio o1,o2,o3;
cout<<"Enter Num and Den of Ratio 1 :";
o1.get();
cout<<"Ratio 1:";
o1.show();
cout<<"Enter Num and Den of Ratio 2 :";
o2.get();
cout<<"Ratio 2:";
o2.show();
o3=o1+o2; //o1.operator +(o2)
cout<<"Addition of 2 ratios :";
o3.show();
cout<<"Division of 2 ratios :";
o3=o1/o2; //o1.operator /(o2)
o3.show();
getch();
}
OUTPUT:
Practical 8:
Implementing Inheritance.
Algorithm:
Input: Roll number and name of a Student is given by the user. Marks of 2 subjects and sports
marks is given by the user.
Output: Marks of all the subjects, the total marks scored by the student with the percentage
secured is displayed to the user.
Steps:
1. Start
2. Create Class Student with protected data memebers - Roll, name and member
functions getinfo(), showinfo().
3. Create Class test as child class of Student with protected data members – marks 1
and marks 2 and member functions getmarks() & showmarks().
4. Create Class sports with protected data member – sports marks and member
functions getsports() and showsports()
5. Create class result as the child class of test and sports with data members = Total
marks and percentage; member functions calculate() & showresult().
6. Create an object of result class
7. Call getinfo()
8. Call getmarks()
9. Call getsports()
10. Call calculate()
11. Call showinfo()
12. Call showmarks()
13. Call showsports()
14. Call showresult()
15. Stop
FlowChart:
START
Define class Student with protected data
memebers – Roll number, name and member
functions getinfo(), showinfo().
Define class test as child class of
Student with protected data members –
m1 and m2 and member functions
getmarks() & showmarks().
Define Class sports with protected data member
– sports marks and member functions
getsports() and showsports().
Define class result as the child class of
test and sports with data members =
total and percentage and member
functions calculate() & showresult().
Create an object of class result
Call getinfo(),getmarks(),getsports(),calculate()
Call showinfo(),showmarks() showsports(),
showresult()
STOP
getinfo() showinfo()
START START
Input roll number as Print roll and name of
roll and name as name student
STOP STOP
getmarks() showmarks()
START START
Input marks of 2 Print marks of two
subjects as m1 & m2 subjects
STOP STOP
getsports() showsports()
START START
Input marks of sports Display sports marks
as spmarks
STOP STOP
calculate() showresult()
START START
Calculate the total Print total marks and
marks and percentage percentage
STOP STOP
/*Implementing Inheritance */
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int roll;
char name[20];
public:
void getinfo()
{
cout<<"Enter rollno and name :";
cin>>roll>>name;
}
void showinfo()
{
cout<<"Roll No :"<<roll<<endl;
cout<<"Name :"<<name<<endl;
}
};
class test : public student
{
protected:
int m1,m2;
public:
void getmarks()
{
cout<<"Enter marks of Subject 1:";
cin>>m1;
cout<<"Enter marks of Subject 2:";
cin>>m2;
}
void showmarks()
{
cout<<"Subject 1 Marks :"<<m1<<endl;
cout<<"Subject 2 Marks :"<<m2<<endl;
}
};
class sports
{
protected:
int spmarks;
public:
void getsports()
{
cout<<"Enter Sports marks :";
cin>>spmarks;
}
void showsports()
{
cout<<"Sports Marks :"<<spmarks<<endl;
}
};
class result : public test, public sports
{
int total,per;
public:
void calculate()
{
total=m1+m2+spmarks;
per=total/3;
}
void showresult()
{
cout<<"Total Marks :"<<total<<endl;
cout<<"Percentage :"<<per;
}
};
void main()
{
clrscr();
result s;
s.getinfo();
s.getmarks();
s.getsports();
s.calculate();
s.showinfo();
s.showmarks();
s.showsports();
s.showresult();
getch();
}
OUTPUT:
Practical 9:
Using Virtual Function.
Algorithm:
Input: No input from user
Output: Output of virtual function in parent class and overridden function in child class is
displayed
Steps:
1. Start
2. Create parent class Person with virtual member function print()
3. Create class Student which inherits from class Person with overridden function print()
4. Create an object p1 and pointer *p of class person.
5. Assign p=&p1.
6. Call print function of person class.
7. Create an object of Student class s1.
8. Assign p=&s1.
9. Call print function of student class.
10. Stop
class person print() [Virtual function]
1. Start
2. print “Name of person : BOB”
3. Stop
class student print() [Overridden function]
1. Start
2. print “Name of student : TOM”
3. Stop
FlowChart:
START
Define a class ‘person’ with virtual
member function print()
Define a class ‘student’ with
overridden member function print()
Create an object p1 and pointer
*p of class person.
p=&p1
Call print()
Create an object of student class
s1.
p=&s1
Call print()
STOP
class person print() class student print()
START START
Print “Name of Print “Name of
Person :BOB" student :TOM"
STOP STOP
/*Using Virtual Function*/
#include<iostream.h>
#include<conio.h>
class Person
{
public:
virtual void print()
{
cout<<"Name of person :BOB"<<endl;
}
};
class Student : public Person
{
public:
void print()
{
cout<<"Name of student :TOM";
}
};
void main()
{
clrscr();
Person *p,p1;
p=&p1;
p->print();
Student s1;
p=&s1;
p->print();
getch();
}
OUTPUT:
Practical 10:
File Handling in C++.
Algorithm:
Pre-requisites: Country file and capital file should be created
Input: Country file name and capital file name
Output: Countries and their capitals are displayed
Steps:
1. Start
2. Declare 2 objects of the input file stream(ifstream); one for the country file and one for
the capital file
3. Take the country file name from the user and open it
4. If the file is not found display a suitable message to the user
5. Take the capital file name from the user and open it
6. If the file is not found display a suitable message to the user
7. Up: If the end of country file is not reached
a. Get a line of the country file into str1
b. Display str1
c. Get a line of the capital file into str2
d. Display str2
e. Go to Up
8. Close the capital file
9. Close the country file
10. Stop
FlowChart:
START
Take the country file name
from the user
Open the country file
If the Yes
country Display country
file is file is not found
not
found
No
A
Take the capital file name
from the user
Open the capital file
B
B
If the Yes
capital
Display capital
file is
file is not found
not
found
No A
Is it the Yes
end of
country A
file
No
Getline from country file
into str1
Display str1
C
C
Getline from capital file
into str2
Display str2
Close the capital file
Close the country file
STOP
/*File Handling*/
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void main()
{
ifstream fcountry;
ifstream fcapital;
char fnm1[20],fnm2[20],str1[20],str2[20];
clrscr();
cout<<"\nEnter country filename-";
cin>>fnm1;
fcountry.open(fnm1);
if(!fcountry)
cout<<"\n Country file not found";
else
{
cout<<"\nEnter capital filename-";
cin>>fnm2;
fcapital.open(fnm2);
if(!fcapital)
cout<<"\n Capital file not found";
else
{
while(!fcountry.eof())
{
fcountry.getline(str1,20,'\n');
cout<<str1<<"\t";
fcapital.getline(str2,20,'\n');
cout<<str2<<endl;
}
}
}
fcapital.close();
fcountry.close();
getch();
}
OUTPUT:
Practical 11:
Creating a web page with tables and images, hyperlink feature and background
color.
HTML PROGRAM
<html>
<title>My Web Page</title>
<body bgcolor="pink">
<h2><marquee>welcome to my page</marquee></h2>
<br></br>
<table border="1">
<tr><td colspan="2">Computer Science</td>
<td colspan="2">Chemistry</td>
<td colspan="2">Physics</td></tr>
<tr><td>Theory</td>
<td>Pracs</td>
<td>Theory</td>
<td>Pracs</td>
<td>Theory</td>
<td>Pracs</td></tr>
<tr><td>80</td>
<td>60</td>
<td>50</td>
<td>80</td>
<td>70</td>
<td>59</td></tr>
<tr><td>50</td>
<td>60</td>
<td>35</td>
<td>47</td>
<td>75</td>
<td>46</td></tr>
</table>
<br></br>
<A href="http://www.vidyavalleynp.in/"><img src="C:\Users\Public\Pictures\Sample
Pictures\Chrysanthemum.jpg"
alt="picture file" width=200 height=200></img></a>
</body>
</html>
Practical 12:
Creating simple HTML page on the topic: Software Development Company. The
page must have atleast 3 paragraphs of text. The page must have an
appropriate title, background color and hyperlink to other pages. The
paragraphs must have text consisting of different colors.
<html>
<head>
<title>Binsoft.com</title>
</head>
<body bgcolor="#d6fa98">
<h1 align="center" style="color:green">BINSOFT</h1>
<hr>
<p><font color="red">Welcome to Binsoft Pvt. Ltd. one of the most leading companies
in the sofware industries.One of the foremost companies in this industry with over 25 years of
Experience</font></p>
<p><font color="green">Our Softwares include a variety of uses like Pagers,Pay
roll,AIML etc.Our work in AI and ML has made an remarkable progess in the world helping many
SME,Enterprises in their requirements</font></p>
<p><font color="blue">Leading company with leading clients in computer
industries.With over 25 Years of expirence with most languages as PHP,Python,Ruby,Java etc and
developed many applications as per the need of our clients</font></p>
<a href="C:/Users/Admin/OneDrive/Documents/client.html">Click Here to know our
clients</a>
<hr>
<h2>Contact Us To Know more </h2>
<p><b>Tel.</b> <a href="tel:09999999999">099999999</a></p>
<p><b>Email.</b> <a
href="mailto:support@binsoft.com">support@binsoft.com</a></p>
<p><b>Addr.</b> Binsoft Softwares Pvt. Ltd. Ganesh Arcade Floor 3,4 Pune,411011</p>
<hr>
</body>
</html>
# FILE NAME : client.html
# CODE
<html>
<head>
<title>Binsoft Clients</title>
</head>
<body bgcolor="#d6fa98">
<h1 align="center"><font color="green">BINSOFT</font></h1>
<h2 align="center"><font color="green">Our Clients</font></h2>
<p align="center" ><a href=" binsoft.html ">Home</a></p>
<hr>
<ol>
<li>ABS Enginnerings</li>
<li>RL Advanced Enginnerings</li>
<li>RD Techsoft</li>
<li>Techfins</li>
<li>FinMines</li>
<li>RS Logistics</li>
</ol>
<hr>
</body>
</html>
Practical 13:
To calculate area of circle and rectangle based on selection
Private Sub area_Click()
If optcircle.Value = True Then
txtarea.Text = 3.14 * Val(txtrad.Text) * Val(txtrad.Text)
ElseIf optrect.Value = True Then
txtarea.Text = Val(txtlen.Text) * Val(txtbr.Text)
End If
End Sub
Private Sub optcircle_Click()
txtlen.Enabled = False
txtbr.Enabled = False
txtrad.Enabled = True
txtrad.Text = ""
txtlen.Text = ""
txtbr.Text = ""
txtarea.Text = ""
txtrad.SetFocus
End Sub
Private Sub optrect_Click()
txtrad.Enabled = False
txtlen.Enabled = True
txtbr.Enabled = True
txtrad.Text = ""
txtlen.Text = ""
txtbr.Text = ""
txtarea.Text = ""
txtlen.SetFocus
End Sub
Practical 14:
To Calculate Sum of first 100 Numbers
Private Sub Command1_Click()
Dim i As Integer, sum As Integer
sum = 0
i=1
Do
List1.AddItem i
sum = sum + i
i=i+1
Loop While (i <= 100)
Label1.Caption = "Sum of 1..100 numbers :" & sum
End Sub
Practical 15:
Accepting marks of a student and displaying result:
Dim total, i As Integer
Dim average As Double
Private Sub averagebtn_Click()
avg.Caption = total / i
average = total / i
Grade.Enabled = True
RESULTbtn.Enabled = True
End Sub
Private Sub Command3_Click()
Dim n As Integer
If Text1.Text = "" Then
MsgBox ("Enter marks")
Text1.SetFocus
Else
n = CInt(Text1.Text)
Text1.Text = ""
Listofmarks.AddItem (n)
total = total + n
i=i+1
donebtn.Enabled = True
End If
End Sub
Private Sub donebtn_Click()
averagebtn.Visible = True
Label2.Visible = True
avg.Visible = True
RESULTbtn.Visible = True
RESULTbtn.Enabled = False
Grade.Visible = True
Grade.Enabled = False
Label1.Enabled = False
Text1.Enabled = False
Command3.Enabled = False
Label3.Enabled = False
Listofmarks.Enabled = False
donebtn.Enabled = False
End Sub
Private Sub Form_Load()
averagebtn.Visible = False
Label2.Visible = False
avg.Visible = False
RESULTbtn.Visible = False
Grade.Visible = False
donebtn.Enabled = False
End Sub
Private Sub RESULTbtn_Click()
If average > 60 Then
Grade.Caption = "WELL DONE. Distinction"
Else
Grade.Caption = "WELL DONE. Grade B"
End If
End Sub