Posts

Showing posts from February, 2015

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading #include<stdio.h> #include<conio.h> #include<iostream.h> #include<float.h> class bubble { public:void array(int ans);        void array(float ans); }; void bubble:: array(int ans)        {        cout<<"\n"<<ans;        } void bubble::array(float ans)        {        cout<<"\n"<<ans;        } int main() { bubble bb; int i,j,n,a[20],temp=0; float b[20]; clrscr(); cout<<"\n Enter how many integer number you want to enter:-"; cin>>n; for(i=0;i<n;i++) cin>>a[i]; n=n-1; for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1]; a[j+1]=te...

Write a C++ program to Design a class which contain static data member and member function show()

Design a class which contain static data member and member function show() which display number of times display operation is performed irrespective of the object responsible for display using static data member. #include<conio.h> #include<iostream.h> class number { public:static int cnt; public:static void show()        {        cnt++;        cout<<"\n Number of times display operation is performed:-"<<cnt;        } }; int number::cnt; int main() { number n1,n2,n3,n4; clrscr(); n1.show(); n2.show(); n3.show(); n4.show(); getch(); return 0; } ================================================== OUTPUT Number of times display operation is performed:-1 Number of times display operation is performed:-2 Number of times display operation is performed:-3 Number of times display operation is performed:-4

Write a c++ program using class to calculate cube and square of a given number using inline function.

Write a c++ program using class to calculate cube and square of a given number using inline function. #include<iostream.h> #include<conio.h> class calc { int no; public:inline void number()        {        int square,cube;        cout<<"Enter the number";        cin>>no;        square=no*no;        cube=no*no*no;        cout<<"Square of a given number is:-"<<square;        cout<<"\n Cube of a given number is:-"<<cube;        }        }; int main() { calc c; clrscr(); c.number(); getch(); return 0; } ====================================================== OUTPUT:- Enter the number5 Square of a given number is:-25 Cube of a given number is:-...

Write a c++ program using class to overload the operator unary decrement -- for an integer number.

Write a c++ program using class to overload the operator unary decrement -- for an integer number. #include<conio.h> #include<iostream.h> class decrement { public:int no; public:void getdata()        {        cout<<"\n Enter the number:-";        cin>>no;        }        void operator --()        {        no=no-1;        }        void display()        {        cout<<"\n The number after decrement is:-"<<no;        } }; int main() { decrement i; clrscr(); i.getdata(); --i; i.display(); getch(); return 0; } ================================================== OUTPUT Enter the number:-6 T...

Write a c++ program using class to overload the operator unary increment ++ for an integer number.

Write a c++ program using class to overload the operator unary increment ++ for an integer number. #include<conio.h> #include<iostream.h> class increment { public:int no; public:void getdata()        {        cout<<"\n Enter the number:-";        cin>>no;        }        void operator ++()        {        no=no+1;        }        void display()        {        cout<<"\n The number after increment is:-"<<no;        } }; int main() { increment i; clrscr(); i.getdata(); ++i; i.display(); getch(); return 0; } ========================================= OUTPUT Enter the number:-2 The number after...

VB program to dispaly age from birth date

Image
Design Window:- Code: Private Sub cmdClear_Click()     Text1.Text = ""     Text2.Text = ""     Text1.SetFocus End Sub Private Sub cmdDisplay_Click()     Dim b As Date     Dim d As Date     Dim age As Date     b = Text1.Text     d = Format$(Now, "dd/mm/yyyy hh:mm:ss ")     age = Format$(d - b, "dd/mm/yyyy hh:mm:ss")         Text2.Text = Year(age)     Text3.Text = Month(age)     Text4.Text = Day(age)     Text5.Text = Hour(age)     Text6.Text = Minute(age)     Text7.Text = Second(age) End Sub Private Sub cmdExit_Click()     Unload Me End Sub =================================================== OUTPUT

Write a c++ program using class to read the name of user and number of units consumed and printout charges with name(Electricity)

An electricity board charges the following rates to users -for first 100 units:40p per unit -for next 200 units: 50p per unit -for beyond 300 units :60p per unit all user are charged a minimum of Rs.150. if the total cost is more than Rs.250 then an additional charges of 15% are added. write a c++ program using class to read the name of user and number of units consumed and printout charges with names.(use array of object) #include<conio.h> #include<iostream.h> class elec { char name[20]; int nou; float charge; public:void accept()        {        cout<<"\n enter name:-";        cin>>name;        cout<<"\n enter number of unit:-";        cin>>nou;        }        void calc()        { ...

Write a C++menu driven program to show class hierarchy.

Consider the following class hierarchy.     Create a base class Employee(empcode, empname). Derive the classes Manager(designation, clubdues), Scientist(deptname, publications) and Labourer from Employee class. Write a C++ menu driven program 1.    to accept  the details of ‘n’ employees 2.    to display the information 3.    to display all the scientist from “Chemistry Department”. #include<conio.h> #include<iostream.h> #include<string.h> #include<stdlib.h> char ans[20]; int ch,n,a=0,b=0,i,cnt; class employee { protected:int empcode;        char empname[20]; }; class manager:protected employee { protected:char desg[20];       int dues; public:void accept1();        void display1(); }m[10]; void manager::accept1() { cout<<"\n enter employee code:-"; cin>>empcode; cout<<"\n enter employee name:-"; cin...

Write a C++ program to create class currency using operator overloading

Write a C++ program to create class currency using operator overloading: Create a class currency containing rupees and paisa as data members. Write a necessary member function using operator overloading for the  following. 1.currency(long int rup=0,int paisa=0) 2.currency &operator +=(currency &)to add one currency to another 3.currency & operator -=(currency &) to subtracts one currency from another  accept rupees & paisa from user and display it. #include #include class currency { int r,p; public:currency(long int rs=0,int paisa=0)        {        r=rs;        p=paisa;        }        currency  & operator +=(currency &);        currency  & operator -=(currency &); }; currency & currency :: operator +=(currency &c2) { i...

Write a C++ program to reverse case of each alphabet in the string

Consider the following class mystring class mystring { char str[100]; public:\\methods }; overload operator "!" to reverse case of each alphabet in the string #include<iostream.h> #include<string.h> #include<conio.h> class mystring { char str[100]; public:void accept()        {        cout<<"\n Enter string:-";        cin>>str;        }        void operator !(); }; void mystring::operator !()        {        int len;        len=strlen(str);        cout<<"\n Reverse string is:-";        for(int i=len-1;i>=0;i--)        cout<<str[i];        } int main() { mystring m1; clrscr(); m1.accept...

Write a visual basic program for stopwatch

Image
Write a visual basic program for stopwatch:- Design Window:- Code:- Dim starttime As Date Dim s As Date Private Sub Reset_Click() Timer1.Enabled = False starttime = Now Timer1.Enabled = True End Sub Private Sub Start_Click() starttime = Now Timer1.Enabled = True End Sub Private Sub Stop_Click() Timer1.Enabled = False Label1.Caption = "" End Sub Private Sub Form_Load() Timer1.Enabled = False End Sub Private Sub Pause_Click() If Pause.Caption = "Pause" Then Timer1.Enabled = False s1 = Label1.Caption Pause.Caption = "Play" End If If Pause.Caption = "Play" Then     Label1.Caption = s1     Timer1.Enabled = True End If End Sub Private Sub Timer1_Timer() Label1.Caption = Format$(Now - starttime, "hh:mm:ss:ms") End Sub ============================================ OUTPUT

Write a visual program to calculate average using runtime textbox

Image
Write a visual program to calculate average using runtime text-box Design window:- Code: Dim t1 As TextBox Dim t2 As TextBox Dim t3 As TextBox Dim t4 As TextBox Dim a As Integer Dim b As Integer Dim c As Integer Private Sub cmdClear_Click() t1.Text = "" t2.Text = "" t3.Text = "" t4.Text = "" t1.SetFocus End Sub Private Sub cmdDisplay_Click()  a = Val(t1.Text)  b = Val(t2.Text)  c = Val(t3.Text)  t4.Text = (a + b + c) / 3 End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub Form_Activate()     Set t1 = Controls.Add("VB.TextBox", "t1")     t1.Visible = True     t1.Height = 600     t1.Width = 2200     t1.Top = 100     t1.Left = 3200     t1.SetFocus                 Set t2 = Controls.Add("VB.TextBox", "t2")     t2.Visible = True     t2.Height = 600     t2.Width = 2200   ...

Write a Visual Basic program to implement the find and replace dialogue box for text-box

Image
Design an application in Visual Basic to implement the find and replace dialogue box for text-box control with multiple line of text with 3 option buttons and check boxes Design window of form:- Code:- Dim txt As String Dim s, l, r As Integer Private Sub Check1_Click(Index As Integer)     If Check1(0).Value = 1 Then         Text1.Font.Bold = True     Else         Text1.Font.Bold = False     End If     If Check1(1).Value = 1 Then         Text1.Font.Italic = True     Else         Text1.Font.Italic = False     End If     If Check1(2).Value = 1 Then         Text1.Font.Underline = True     Else         Text1.Font.Underline = False     End If End Sub Private Sub cmdClear_Click() Option1(0).Value = False Option2(1).Value = False Option3(2).Value = False C...

Write a Visual Basic Program to make customer Survey and with their name and then display the survey result.

Image
Write a Visual Basic Program to make customer Survey and  with their name and then display the survey result. ------------------------------------------------------------------------------------------ Design Window:-  First Form :- Second form:- Code;- Dim Excellent As Integer Dim Satisfactory As Integer Dim Average As Integer Dim Bad As Integer Dim Total As Integer Private Sub cmdContinue_Click() If optExcellent.Value Then     Excellent = Excellent + 1 ElseIf optSatisfactory.Value Then     Satisfactory = Satisfactory + 1 ElseIf optAverage.Value Then     Average = Average + 1 Else     Bad = Bad + 1 End If txtName.Text = "" optExcellent.Value = False optSatisfactory.Value = False optAverage.Value = False optBad.Value = False txtName.SetFocus End Sub Private Sub cmdQuit_Click() Total = Excellent + Satisfactory + Average + Bad With frmServeyResult     .lblExcellent = Excellent    ...

Write a Visual Basic program to find the mouse position on screen and number click made by user on screen.

Image
Write a Visual Basic program to find the mouse position on screen and number click that is Left, Right and Double made by user on screen form . First Design Form Window (mousepose.frm):- Second Design Form Window (summary.frm):- Code:- for first form Dim cnt As Integer Dim cnt1 As Integer Dim cnt2 As Integer Private Sub Command1_Click() Form2.Show Form2.Text1.Text = cnt Form2.Text2.Text = cnt1 Form2.Text3.Text = cnt2 End Sub Private Sub Form_DblClick() cnt2 = cnt2 + 1 LblDblClick.Caption = cnt2 End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then     cnt = cnt + 1     LblLeftClick.Caption = cnt End If If Button = vbRightButton Then     cnt1 = cnt1 + 1     LblRightClick.Caption = cnt1 End If End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim strpos As String Dim xpos As Integer ...

Write a Visual Basic program to calculate Sum of the Even digits of a given number.

Image
  Write a Visual Basic program to calculate Sum of the Even digits of a given number. Designing window :- Take the following tools form toolbox in form. Code:- Private Sub cmdClear_Click() Text1.Text = "" Text2.Text = "" Text1.SetFocus End Sub Private Sub cmdSum_Click()     n = Val(Text1.Text)     While n > 0         r = n Mod 10         n = n \ 10         If r Mod 2 = 0 Then             s = s + r         End If         Text2.Text = s     Wend End Sub Private Sub cmFxit_Click() Unload Me End Sub Private Sub Form_Activate() Text1.SetFocus End Sub =================================== OUTPUT

Write a visual Basic Program to show tool bar

Image
Designing Window :- First step right click on toolbox and add components it will show components popup window from it on control tab add Microsoft Windows Common Controls 6.0 (SP6) click on check box of selected items only and then click on OK button .It will show more tools like tool bar and image list on toolbox take it on form window and write the below code in coding window.                             Fig :- Design View of program for taking tool bar on form Code:- Private Sub Form_Load() Toolbar1.ImageList = ImageList1 Dim b1 As Button Set b1 = Toolbar1.Buttons.Add b1.Style = tbrDefault b1.Caption = "New" b1.Image = 1 Dim b2 As Button Set b2 = Toolbar1.Buttons.Add b2.Style = tbrDefault b2.Caption = "Open" b2.Image = 2 Dim b3 As Button Set b3 = Toolbar1.Buttons.Add b3.Style = tbrDefault b3.Caption = "Save" b3.Image = 3 Dim b4 As Button Set b4 = Toolbar1.Buttons.Add b4.Style = tb...

Write a C++ program to calculate area of circle,sphere and cylinder using base class round-shape

Create a base class round-shape(radius). define three different shapes as circle, sphere and cylinder(height) from round-shape. class round-shape { protected :float radius; public:static float pi; round-shape(float)//default argument virtual float area()=0; } Write a C++ program to calculate area of circle,sphere and cylinder #include<iostream.h> #include<conio.h> class round { protected:float radius; public:static float pi;        round(float r=0)        {        cout<<"\n Enter the radius:-";        cin>>r;        radius=r;        }        virtual float area()=0;        }; class circle:public round { public:float circle;        float area()        {   ...

Write a cpp program for car passing through toll booth

Imagine a tollbooth at a bridge. a car passing by the booth is expected to pay a toll. the tollbooth keeps the track of the number car that gone and total cash amount collected. create a class tollbooth with the data member -total number of cars passed -total toll collected write necessary member function 1.a constructor that initializes both data member to zero. 2.paying ca(): when any cars passes through the tollbooth. that much toll gets added into total toll collected and total number of cars passed is incremented by one 3. nonpaying car(); increment the car total but adds nothing to cash total 4.display(); the total number car passed and total cash collected #include<iostream.h> #include<conio.h> class toolbath { int noc,tot; public:tollbooth(int n=0,int t=0)        {        noc=n;        tot=t;        }        void pay...