MPLS
stands for Multi-protocol label switching
Thursday 9 June 2016
What is a Layer 2 MPLS VPN?
- Uses an MPLS network in the provider core to deliver Layer 2 services to the customers.
- Uses EoSDH, IPRAN and IPCORE Backhaul for the connectivity.
- Has Ethernet Interface (FE or GE) as connectivity to customer router.
Is MPLS an alternative to IP?
- \ No.
- There are many, many things that MPLS can't do. It's a supplement to IP to provide additional connection oriented capabilities to the network.
- MPLS is Layer 2.5 technology while IP is layer 3.
What are the goals of a Layer 2 MPLS VPN?
- A Layer 2 MPLS VPN is exactly the same as a Layer 2 VPN.
- A Layer 2 MPLS VPN allows the use of a single network technology (namely, MPLS) to offer many services, including IP, Layer 2 VPNs, Layer 3 VPNs, MPLS traffic engineering, and Differentiated Services (DiffServ).
- A single network architecture that offers multiple services is often referred to as a converged network.
- A single access line to provide multiple services is also beneficial to a service provider.
What are alternate Layer 2 MPLS VPN proposals?
More than one Layer 2 MPLS VPN
architecture has been under consideration by the Provider-provisioned Virtual
Private Network Working Group (PPVPN WG) of the IETF. The primary proposals
were known as draft-Kompella and draft-Martini, and these were the file names
of the versions of those drafts as of November 2001:
■Draft-martini-l2circuit-trans-mpls-07.txt
■Draft-martini-l2circuit-encap-mpls-03.txt
■Draft-kompella-ppvpn-l2vpn-00.txt
Note:
Be sure to check the Internet
Drafts http://www.ietf.org/ID.html section of the IETF Web site
for updates, because the drafts change often. The answer to question number 12
explains the status of those drafts in November 2001.
When should a service provider deploy a Layer 2 MPLS VPN rather than another VPN technology?
The simplest case is when the service
provider’s customer is already using a Layer 2 VPN. Migration is fairly
straightforward in this case. Other situations where a Layer 2 MPLS VPN is
preferable are when a service provider is using non-IP protocols or has a large
number of routes in its network. An important factor to note in contrasting
Layer
2 and Layer 3 MPLS VPNs is that Layer 2
MPLS VPNs usually require the provider’s customer to have more routing
expertise.
How is a Layer 2 MPLS VPN different from a Layer 3 MPLS VPN?
The main difference, from the service
provider’s point-of-view, is that there is no Layer 3 routing information
exchange between the customer and the service provider. The other difference is
that the service provider does not need to care nor to know what network-layer
protocol the customer uses. On the flip side, Layer 2 MPLS VPNs currently
require that all sites in the service provider’s customer network connect to
the service provider with the same Layer 2 technology (for example, that all
use Frame Relay). This Layer 2 dependence gives the customer Layer 3
independence, because the customer can run any Layer 3 protocol. There is also
an intermediate solution, called Layer 2 interworking, whereby each
customer site can connect with a different
Layer 2 technology, but the Layer 3 protocol is limited to IP. In a Layer 3
MPLS VPN, however, the various sites can connect with any technology.
How is it different from Circuit Cross-connect?
There are two major advantages of Layer 2
MPLS VPNs over Circuit Cross-connect: First, with Circuit Cross-connect, you
must configure point-to-point circuits. Building a VPN in this manner is
tedious, because adding or removing a site requires a fair amount of work, as
well as touching lots of routers. With Layer 2 MPLS VPNs, you can configure a
VPN specifically, so the configuration is much more straightforward. Adding or
removing a site is also much simpler, and in many cases it involves touching
only the one router attached to the site. Second, each Circuit Cross-connect
requires a dedicated provider edge-to-provider edge label-switched path
(PE-to-PE LSP), and this LSP must be signalled by using
RSVP. (Using Label Distribution Protocol
[LDP] makes no sense in a Circuit Cross-connect, point-to-point scenario,
because it employs a reverse-path tree approach.) Layer 2 MPLS VPNs use label
stacking, so a single PE-to-PE LSP can be used for multiple VPNs and, in fact,
for multiple services. This makes it an extremely scalable technology.
Furthermore, this LSP can be set up through any means, including RSVP and LDP.
Label-stacking techniques also support greater infrastructure scalability.
What are the benefits of a Layer 2 MPLS VPN to a service provider and to an enterprise customer?
To a service provider, this is a
significant migration step toward a single IP- and MPLS-based infrastructure
for all services. Existing tail-circuit technology (Frame Relay or ATM) can be
re-used. This not only makes the transition familiar to operators and maximizes
the service provider’s investment, but also retains the operational simplicity
of those existing technologies (thus no responsibility for customer routing).
Auto provisioning makes deployment easier at scale. By using label-stacking
techniques, Layer 2 MPLS VPNs are specifically designed for scalability and for
deployment in carrier-of-carriers environments. For enterprise customers, the
scalability of this technology is well-suited to large corporations.
MPLS can provide
multiprotocol connectivity (IPX and SNA, for instance), and it also easily
supports IP multicasting. Customers that are accustomed to managing their own
routing domains can continue to do so. They can also deploy extra security,
such as IPSec encryption.
Will MPLS replace Frame Relay or ATM as the VPN technology of choice?
· Layer 2 MPLS VPNs allow service providers full freedom to choose internal network technologies independent of the Layer 2 VPN service offerings.
· Currently most VPN networks are based on MPLS technology. Customer prefer MPLS VPN because of its flexibility, scalability and multilevel protection offered by IP network.
Could IPSec be transported over Kompella and Martini Internet Draft-based VPN networks?
Certainly. If the customer
wants more security than is provided by simple isolation, Encryption, or
authentication, using IPSec or other means would complement Layer 2 MPLS VPNs
well. In fact, this is highly recommended.
Monday 6 June 2016
MPLS VPN
What is MPLS VPN?
MPLS VPN is a family of methods for harnessing the power of multiprotocol label switching (MPLS) to create virtual private networks (VPNs). MPLS VPN gives network engineers the flexibility to transport and route several types of network traffic using the technologies of a MPLS backbone.
Keeping pace with the technological trend to provide latest and varied value added services to its customers, Service Provider harnesses IP Infrastructure based on MPLS Technology to offer world class IP VPN services.
MPLS is an acronym for "Multi Protocol Label Switching".
MPLS(Multi Protocol Label Switching) VPN is a technology that allows a Service Provider to have complete control over parameters that are critical to offering its customers service guarantees with regard to bandwidth throughputs, latencies and availability.
The technology enables secure Virtual Private Networks (VPN) to be built and allows scalability that will make it possible for Service Provider to offer assured growth to its customers without having to make significant investments.
Service Provider would now be geared to provide Bandwidth on demand, Video Conferencing, Voice Over IP (VoIP) and a host of other value added services that could revolutionize the way a corporate business works!
Opening, Closing, and Hiding Forms with Visual Basic .NET
Opening,Showing, Closing, and Hiding Forms with Visual Basic .NET
NOTE-Before you can open (or close) a form, you need to know the specific name of the form you want to open or close. The Solution Explorer window lists the names of all the forms that make up your Visual Basic .NET program, such as a form named frmMain.vb.
Opening a form:
After you know the name of the form that you want to display, you need to use BASIC command to open the form, such as the following:
Dim oForm As FormName
oForm = New FormName()
oForm.Show()
oForm = Nothing
oForm = New FormName()
oForm.Show()
oForm = Nothing
Hiding a form
If you want to temporarily make a form disappear, you can use the magic Hide command, such as:
FormName.Hide()
Showing a form
After you've hidden a form, you'll eventually want to make it visible again by using the Show command, such as:
FormName.Show()
Closing a form
Hiding a form just tucks it out of sight, but the form is still loaded in the computer's memory. To clear a form out of memory, you need to use the Close command, such as:
FormName.Close()
How to: Add Windows Forms to a Project(Inserting a Form into a Project)
Inserting a Form into a Project
To insert a form into your project
- From Class View, select the project to which you want to add the form, and click the right mouse button.
- From the shortcut menu, click Add and then click Add Class.If the New Form command is not available, your project may be based on the Active Template Library (ATL). To add a form to an ATL project, you must specify certain settings when first creating the project.
- From the MFC folder, click MFC Class.
- Using the MFC Class Wizard, make the new class derive from CFormView.
Visual C++ adds the form to your application, opening it inside the Dialog editor so that you can begin adding controls and working on its overall design.
Sources: https://msdn.microsoft.com/en-us/library/fhxbke21.aspx
Sunday 5 June 2016
How to: Delete records from SQL table in VB.Net
How to: Delete records from SQL table in VB.Net
Code to delete a record from SQL table using VB.Net is as follows:
Note-
1: Double Click the delete button and copy the following code
2:And also change the server in connection string and the database also
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Try
con.ConnectionString = "Server=.\SQLEXPRESS;Database=Employee Details;Trusted_Connection=True"
con.Open()
cmd.Connection = con
cmd.CommandText = "Delete From emp_det where emp_id like @emp_id"
cmd.Parameters.Add(New SqlParameter("@emp_id", TextBox1.Text))
cmd.ExecuteNonQuery()
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
MsgBox("Operation Cancelled")
Exit Sub
End If
Catch ex As Exception
MessageBox.Show("Error while deleting record on table..." & ex.Message, "Delete Records")
Finally
con.Close()
End Try
End Sub
Allow Numbers only in a TextBox - Visual Basic .NET
So the code for allowing only numbers in the textbox for employee ID is:
Just copy the code in the box given below:Private Sub TextBox1_KeyPress( ByVal sender As Object , ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then MessageBox.Show( "Please enter numbers only" ) e.Handled = True End If End Sub |
The Result:
Wednesday 11 May 2016
Stopwatch in VB6
Stopwatch in VB6
This is a stopwatch application in VB6 that uses the Timer control. The user has the option to start, stop and reset the stopwatch.
First create the above design of your program in the form designer and then copy the below code into the code window of the vb.
Code:
Dim smallsec As Integer, sec As Integer, min As Integer
Dim hour As Integer
________________________________________________
Private Sub cmdReset_Click()
cmdStart.Caption = "Start"
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Text1.Text = Format(0, "00")
Text2.Text = Format(0, "00")
Text3.Text = Format(0, "00")
End Sub
________________________________________________
Private Sub cmdStart_Click()
If cmdStart.Caption = "Start" Then
cmdStart.Caption = "Stop"
Else
cmdStart.Caption = "Start"
End If
If cmdStart.Caption = "Stop" Then
Timer3.Enabled = True
Timer2.Enabled = True
Timer1.Enabled = True
Else
Timer3.Enabled = False
Timer2.Enabled = False
Timer1.Enabled = False
End If
End Sub
________________________________________________
Private Sub Timer1_Timer()
If txtMinute.Text < 59 Then
txtMinute.Text = Format(txtMinute.Text + 1, "00")
Else
txtMinute.Text = Format(0, "00")
End If
End Sub
________________________________________________
Private Sub Timer2_Timer()
If txtSecond.Text < 59 Then
txtSecond.Text = Format(txtSecond.Text + 1, "00")
Else
txtSecond.Text = Format(0, "00")
End If
End Sub
________________________________________________
Private Sub Timer3_Timer()
If txtMiniSecond.Text < 99 Then
txtMiniSecond.Text = Format(txtMiniSecond.Text + 1, "00")
Else
txtMiniSecond.Text = Format(0, "00")
End If
End Sub
Dim hour As Integer
________________________________________________
Private Sub cmdReset_Click()
cmdStart.Caption = "Start"
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Text1.Text = Format(0, "00")
Text2.Text = Format(0, "00")
Text3.Text = Format(0, "00")
End Sub
________________________________________________
Private Sub cmdStart_Click()
If cmdStart.Caption = "Start" Then
cmdStart.Caption = "Stop"
Else
cmdStart.Caption = "Start"
End If
If cmdStart.Caption = "Stop" Then
Timer3.Enabled = True
Timer2.Enabled = True
Timer1.Enabled = True
Else
Timer3.Enabled = False
Timer2.Enabled = False
Timer1.Enabled = False
End If
End Sub
________________________________________________
Private Sub Timer1_Timer()
If txtMinute.Text < 59 Then
txtMinute.Text = Format(txtMinute.Text + 1, "00")
Else
txtMinute.Text = Format(0, "00")
End If
End Sub
________________________________________________
Private Sub Timer2_Timer()
If txtSecond.Text < 59 Then
txtSecond.Text = Format(txtSecond.Text + 1, "00")
Else
txtSecond.Text = Format(0, "00")
End If
End Sub
________________________________________________
Private Sub Timer3_Timer()
If txtMiniSecond.Text < 99 Then
txtMiniSecond.Text = Format(txtMiniSecond.Text + 1, "00")
Else
txtMiniSecond.Text = Format(0, "00")
End If
End Sub
Copy-Paste Sample in Visual Basic 6
Copy-Paste Sample in Visual Basic 6
This is a copy paste sample in Visual Basic 6. It shows you how to use the clipboard object in VB6 to perform copy paste operations in your application. This is a very easy sample targeted to the beginners. It shows you the use of the clipboard object very simply and in a straightforward way avoiding the complexities related to this object. Of course, you can make a complex program using the Clipboard object to achieve something of a very high level.
The code for the above program is very simple and two command buttons are used in the program:
1: cmdCopy2: cmdPaste
First create the above design of your program in the form designer and then copy the below code into the code window of the vb.
The code for the above program is very simple and two command buttons are used in the program:
1: cmdCopy2: cmdPaste
First create the above design of your program in the form designer and then copy the below code into the code window of the vb.
Code:
Private Sub cmdCopy_Click()
Clipboard.SetText (txtCopy.Text)
End Sub
Private Sub cmdPaste_Click()
txtPaste.Text = Clipboard.GetText
End Sub
Thank You.
For any other program please comment in the comment box and get any program related to C,C++,VB6 or VB 2010.
Creating Traffic Light Using VB
Creating Traffic Light Using VB
First create the above design of your traffic light in the form designer and then copy the below code into the code window of the vb.
Note:
Fill the circles or ovals made for the traffic lights with the red,yellow and green color before you start coding.
Also, add the three timers from the toolbox.
AS, this is VB 2010 the timers are not visible but if you are using VB 6 the timers will be visible at the side of each light.
So add 3 timers at the side of each coloured circle or oval.
Code:
Private Sub OvalShape2_Click(sender As System.Object, e As System.EventArgs) Handles OvalShape2.Click
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
OvalShape1.Visible = True
OvalShape2.Visible = False
OvalShape3.Visible = False
Timer1.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
OvalShape1.Visible = False
OvalShape2.Visible = True
OvalShape3.Visible = False
Timer2.Enabled = False
Timer3.Enabled = True
End Sub
Private Sub Timer3_Tick(sender As System.Object, e As System.EventArgs) Handles Timer3.Tick
OvalShape1.Visible = False
OvalShape2.Visible = False
OvalShape3.Visible = True
Timer3.Enabled = False
Timer1.Enabled = True
End Sub
Friend WithEvents RectangleShape1 As Microsoft.VisualBasic.PowerPacks.RectangleShape
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Button6 As System.Windows.Forms.Button
Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
Timer1.Enabled = True
OvalShape1.Visible = True
OvalShape2.Visible = False
OvalShape3.Visible = False
End Sub
Friend WithEvents Button7 As System.Windows.Forms.Button
Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
OvalShape1.Visible = False
OvalShape2.Visible = False
OvalShape3.Visible = False
End Sub
End Class
Code for VB 6 Users :
Private Sub Form_Load()
Timer1.Enabled = True
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End Sub
Private Sub Timer1_Timer()
If Shape1.Visible Then
Shape2.Visible = True
Shape1.Visible = False
Shape3.Visible = False
ElseIf Shape2.Visible Then
Shape3.Visible = True
Shape2.Visible = False
Shape1.Visible = False
Else
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End If
End Sub
Calculator using VB
Calculator using VB
First create the above design of your calculator in the form designer and then copy the below code into the code window of the vb.
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox3.Text = TextBox1.Text + TextBox2.Text
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TextBox3.Text = TextBox1.Text - TextBox2.Text
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
TextBox3.Text = TextBox1.Text / TextBox2.Text
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
TextBox3.Text = TextBox1.Text * TextBox2.Text
End Sub
TextBox3.Text = TextBox1.Text + TextBox2.Text
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
TextBox3.Text = TextBox1.Text - TextBox2.Text
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
TextBox3.Text = TextBox1.Text / TextBox2.Text
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
TextBox3.Text = TextBox1.Text * TextBox2.Text
End Sub
Microsoft Virtual Studio
Microsoft Virtual Studio
Its is a rich, integrated development environment for creating stunning applications for Windows, Android, and iOS, as well as modern web applications and cloud services.
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sites, web applications and web services. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both native code and managed code.
The term virtual studio can refer to any number of technological tools which seek to simulate a physical television and/or movie studio.
Visual Studio does not support any programming language, solution or tool intrinsically; instead, it allows the plugging of functionality coded as a VSPackage. When installed, the functionality is available as a Service. The IDE provides three services: SVsSolution, which provides the ability to enumerate projects and solutions; SVsUIShell, which provides windowing and UI functionality (including tabs, toolbars and tool windows); and SVsShell, which deals with registration of VSPackages. In addition, the IDE is also responsible for coordinating and enabling communication between services.[9] All editors, designers, project types and other tools are implemented as VSPackages. Visual Studio uses COM to access the VSPackages. The Visual Studio SDK also includes the Managed Package Framework (MPF), which is a set of managed wrappers around the COM-interfaces that allow the Packages to be written in any CLI compliant language.[10] However, MPF does not provide all the functionality exposed by the Visual Studio COM interfaces.[11] The services can then be consumed for creation of other packages, which add functionality to the Visual Studio IDE.
Wednesday 4 May 2016
Searching element in array using pointers
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],*p,no,flag=0,i;
clrscr();
p=&a[0];
cout<<"Enter Elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
cout<<"Enter no to be searched:";
cin>>no;
for(i=0;i<5;i++)
{
if(*p==no)
{
cout<<"No is present";
flag=0;
break;
}
else
{
flag=1;
}
p++;
}
if(flag==1)
{
cout<<"No not present";
}
getch();
}
#include<conio.h>
void main()
{
int a[5],*p,no,flag=0,i;
clrscr();
p=&a[0];
cout<<"Enter Elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
cout<<"Enter no to be searched:";
cin>>no;
for(i=0;i<5;i++)
{
if(*p==no)
{
cout<<"No is present";
flag=0;
break;
}
else
{
flag=1;
}
p++;
}
if(flag==1)
{
cout<<"No not present";
}
getch();
}
Copying the array elements using pointers.
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],*p,i,b[5],*q;
clrscr();
p=&a[0];
q=&b[0];
cout<<"Enter elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
for(i=0;i<5;i++)
{
*q=*p;
p++;
q++;
}
q=&b[0];
cout<<"Copied String:";
for(i=0;i<5;i++)
{
cout<<" "<<*q;
q++;
}
getch();
}
#include<conio.h>
void main()
{
int a[5],*p,i,b[5],*q;
clrscr();
p=&a[0];
q=&b[0];
cout<<"Enter elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
for(i=0;i<5;i++)
{
*q=*p;
p++;
q++;
}
q=&b[0];
cout<<"Copied String:";
for(i=0;i<5;i++)
{
cout<<" "<<*q;
q++;
}
getch();
}
What is a Pointer ?
A pointer is a memory variable that stores the memory address of another variable.
Friday 29 April 2016
Friend Function Example.
#include<iostream.h>
#include<conio.h>
class square
{
int no;
public:
void accept()
{
cout<<"Enter no for square:";
cin>>no;
}
friend void sq(square s);
};
void sq(square s)
{
int ans;
ans=s.no*s.no;
cout<<"Square="<<ans;
}
void main()
{
clrscr();
square s;
s.accept();
sq(s);
getch();
}
/*Output:
Enter no for square:4
Square=16 */
#include<conio.h>
class square
{
int no;
public:
void accept()
{
cout<<"Enter no for square:";
cin>>no;
}
friend void sq(square s);
};
void sq(square s)
{
int ans;
ans=s.no*s.no;
cout<<"Square="<<ans;
}
void main()
{
clrscr();
square s;
s.accept();
sq(s);
getch();
}
/*Output:
Enter no for square:4
Square=16 */
WAP for finding out the weight on any planet using static data member
#include<iostream.h>
#include<conio.h>
class planets
{
static float g;
float w,m;
int ch;
public:
void accept()
{
cout<<"Find weight on:"<<endl;
cout<<"1:MERCURY\n2:VENUS\n3:EARTH\n4:MARS\n5:JUPITER\n6:SATURN\n7:URANUS\n8:NEPTUNE"<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:
g=3.61;
break;
case 2:
g=8.83;
break;
case 3:
g=9.8;
break;
case 4:
g=3.75;
break;
case 5:
g=26.0;
break;
case 6:
g=11.2;
break;
case 7:
g=10.5;
break;
case 8:
g=13.3;
break;
}
cout<<"Enter mass:";
cin>>m;
}
void display()
{
w=m*g;
cout<<"Weight="<<w;
}
};
float planets::g;
void main()
{
clrscr();
planets p;
p.accept();
p.display();
getch();
}
/*Output:
Find weight on:
1:MERCURY
2:VENUS
3:EARTH
4:MARS
5:JUPITER
6:SATURN
7:URANUS
8:NEPTUNE
Enter your choice:
3
Enter mass:10
Weight=98 */
#include<conio.h>
class planets
{
static float g;
float w,m;
int ch;
public:
void accept()
{
cout<<"Find weight on:"<<endl;
cout<<"1:MERCURY\n2:VENUS\n3:EARTH\n4:MARS\n5:JUPITER\n6:SATURN\n7:URANUS\n8:NEPTUNE"<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:
g=3.61;
break;
case 2:
g=8.83;
break;
case 3:
g=9.8;
break;
case 4:
g=3.75;
break;
case 5:
g=26.0;
break;
case 6:
g=11.2;
break;
case 7:
g=10.5;
break;
case 8:
g=13.3;
break;
}
cout<<"Enter mass:";
cin>>m;
}
void display()
{
w=m*g;
cout<<"Weight="<<w;
}
};
float planets::g;
void main()
{
clrscr();
planets p;
p.accept();
p.display();
getch();
}
/*Output:
Find weight on:
1:MERCURY
2:VENUS
3:EARTH
4:MARS
5:JUPITER
6:SATURN
7:URANUS
8:NEPTUNE
Enter your choice:
3
Enter mass:10
Weight=98 */
Class with Static Data Member
#include<iostream.h>
#include<conio.h>
class account
{
static int r;
int p,n,si;
public:
void accept()
{
cout<<"Enter Principal amount & No. of years:"<<endl;
cin>>p>>n;
}
void display()
{
si=(p*n*r)/100;
cout<<"Simple Interest="<<si;
}
};
int account::r=10;
void main()
{
clrscr();
account a;
a.accept();
a.display();
getch();
}
/*Output:
Enter Principal amount & No. of years:
500 2
Simple Interest=100 */
#include<conio.h>
class account
{
static int r;
int p,n,si;
public:
void accept()
{
cout<<"Enter Principal amount & No. of years:"<<endl;
cin>>p>>n;
}
void display()
{
si=(p*n*r)/100;
cout<<"Simple Interest="<<si;
}
};
int account::r=10;
void main()
{
clrscr();
account a;
a.accept();
a.display();
getch();
}
/*Output:
Enter Principal amount & No. of years:
500 2
Simple Interest=100 */
Subscribe to:
Posts (Atom)