<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>electrofriends.com &#187; c++ class</title>
	<atom:link href="http://electrofriends.com/tag/c-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:43:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.6</generator>
		<item>
		<title>C++ class program to illestrate File operations</title>
		<link>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-class-program-to-illestrate-file-operations/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-class-program-to-illestrate-file-operations/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 18:08:00 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[c++ class]]></category>
		<category><![CDATA[file open]]></category>
		<category><![CDATA[File operations]]></category>
		<category><![CDATA[file write]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1070</guid>
		<description><![CDATA[AIM Write a program to illustrate the write() member function which are usually used for transfer of data blocks to the file. ALGORITHM 1. Start the process 2. Invoke the class a. Create two inline member functions .ie, getdata() and dispdata() i. getdata() for input ii. dispdata() for display 3. Open the file in fstream [...]]]></description>
			<content:encoded><![CDATA[<p><strong>AIM</strong><br />
	Write a program to illustrate the write() member function which are usually used for transfer of data blocks to the file.</p>
<p><strong>ALGORITHM</strong></p>
<p>1.	Start the process<br />
2.	Invoke the class<br />
a.	Create two inline member functions .ie, getdata() and dispdata()<br />
i.	getdata() for input<br />
ii.	dispdata() for display<br />
3.	Open the file in fstream mode<br />
4.	Write the data in to the file<br />
5.	Slose the file<br />
6.	Stop the process</p>
<p><strong>PROGRAM</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include&lt;iostream.h&gt;</span>
<span style="color: #339900;">#include&lt;conio.h&gt;</span>
<span style="color: #339900;">#include&lt;fstream.h&gt;</span>
<span style="color: #0000ff;">class</span> student
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
<span style="color: #0000ff;">int</span> rno<span style="color: #008080;">;</span>
<span style="color: #0000ff;">char</span> name<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">float</span> fees<span style="color: #008080;">;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
<span style="color: #0000ff;">void</span> getdata<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;roll number&quot;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>rno<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;enter name:&quot;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>name<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;enter fees:&quot;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>fees<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> dispdata<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Roll number&quot;</span><span style="color: #000080;">&lt;&lt;</span>rno<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Name&quot;</span><span style="color: #000080;">&lt;&lt;</span>name<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Fees&quot;</span><span style="color: #000080;">&lt;&lt;</span>fees<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
student s1<span style="color: #008080;">;</span>
clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
ofstream stdfile<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;c:<span style="color: #000099; font-weight: bold;">\\</span>std.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//fstream stdfile;</span>
<span style="color: #666666;">//stdfile.open(&quot;c:\\std.txt&quot;,ios::out|ios::in);  //open file for output</span>
<span style="color: #0000ff;">char</span> wish<span style="color: #008080;">;</span>
<span style="color: #666666;">//writing to the file</span>
<span style="color: #0000ff;">do</span>
<span style="color: #008000;">&#123;</span>
s1.<span style="color: #007788;">getdata</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
stdfile.<span style="color: #007788;">write</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;</span>s1,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>student<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;continue ? y/n&quot;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>wish<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>wish<span style="color: #000080;">==</span><span style="color: #FF0000;">'y'</span><span style="color: #000040;">||</span>wish<span style="color: #000080;">==</span><span style="color: #FF0000;">'Y'</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
stdfile.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>   <span style="color: #666666;">//close the file</span>
&nbsp;
getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>OUTPUT</strong></p>
<p>Roll number  121<br />
Enter name  Jacob<br />
Enter fees   10000</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-class-program-to-illestrate-file-operations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>c++ Program to illustrate the use of difference operators using friend function</title>
		<link>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-to-illustrate-the-use-of-difference-operators-using-friend-function/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-to-illustrate-the-use-of-difference-operators-using-friend-function/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 04:29:18 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[c++ class]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[difference operators]]></category>
		<category><![CDATA[friend function]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1048</guid>
		<description><![CDATA[AIM: A program to illustrate the use of difference operators to access the class member using friend function ALGORITHM: 1) Start the process 2) Invoke the classes 3) Call the set_xy() first a) Assign the value of x and y b) Print the value of x and y 4) Call the sum() for second(friend) a) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>AIM: </strong><br />
A program to illustrate the use of difference operators to access the class member using friend function<br />
<strong><br />
ALGORITHM: </strong></p>
<p>1)	Start the process<br />
2)	Invoke the classes<br />
3)	Call the set_xy() first<br />
a)	Assign the value of x and y<br />
b)	Print the value of x and y<br />
4)	Call the sum() for second(friend)<br />
a)	Again assign the temp value of x and y<br />
5)	Print the value of x and y<br />
6)	Stop the process</p>
<p><strong>PROGRAM</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include&lt;iostream.h&gt;</span>
<span style="color: #0000ff;">class</span> M
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">int</span> x<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> y<span style="color: #008080;">;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
<span style="color: #0000ff;">void</span> set_xy<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> a,<span style="color: #0000ff;">int</span> b<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
x<span style="color: #000080;">=</span>a<span style="color: #008080;">;</span>
y<span style="color: #000080;">=</span>b<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">friend</span> <span style="color: #0000ff;">int</span> sum<span style="color: #008000;">&#40;</span>M m<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> sum<span style="color: #008000;">&#40;</span>M m<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">int</span> M <span style="color: #008080;">::</span><span style="color: #000040;">*</span> px<span style="color: #000080;">=</span><span style="color: #000040;">&amp;</span>M <span style="color: #008080;">::</span> <span style="color: #007788;">x</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> M <span style="color: #008080;">::</span><span style="color: #000040;">*</span> py<span style="color: #000080;">=</span><span style="color: #000040;">&amp;</span>M <span style="color: #008080;">::</span> <span style="color: #007788;">y</span><span style="color: #008080;">;</span>
M <span style="color: #000040;">*</span>pm<span style="color: #000080;">=</span><span style="color: #000040;">&amp;</span>m<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> s<span style="color: #000080;">=</span>m.<span style="color: #000040;">*</span>px <span style="color: #000040;">+</span> pm<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #000040;">*</span>py<span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span> s<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
M n<span style="color: #008080;">;</span>
<span style="color: #0000ff;">void</span> <span style="color: #008000;">&#40;</span>M <span style="color: #008080;">::</span> <span style="color: #000040;">*</span>pf<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span>,<span style="color: #0000ff;">int</span><span style="color: #008000;">&#41;</span><span style="color: #000080;">=</span><span style="color: #000040;">&amp;</span>M <span style="color: #008080;">::</span> <span style="color: #007788;">set_xy</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#40;</span>n.<span style="color: #000040;">*</span>pf<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">10</span>,<span style="color: #0000dd;">20</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Sum=&quot;</span><span style="color: #000080;">&lt;&lt;</span>sum<span style="color: #008000;">&#40;</span>n<span style="color: #008000;">&#41;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
M <span style="color: #000040;">*</span>op<span style="color: #000080;">=</span><span style="color: #000040;">&amp;</span>n<span style="color: #008080;">;</span>
<span style="color: #008000;">&#40;</span>op<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span><span style="color: #000040;">*</span>pf<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">40</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Sum=&quot;</span><span style="color: #000080;">&lt;&lt;</span>sum<span style="color: #008000;">&#40;</span>n<span style="color: #008000;">&#41;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">return</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>Output:</strong></p>
<p>	Sum=30<br />
	Sum=70</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-to-illustrate-the-use-of-difference-operators-using-friend-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ program for implementation of class</title>
		<link>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-for-implementation-of-class/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-for-implementation-of-class/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 09:45:07 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[c++ class]]></category>
		<category><![CDATA[C++ Programs]]></category>
		<category><![CDATA[class implementations]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1044</guid>
		<description><![CDATA[AIM: A program to solve a quadratic equation, using OOP techniques. ALGORITHM: 1) Start the process 2) Invoke the classes 3) Get the input for a,b,c; 4) Call the function getinfo() and display() 5) Check if a=0 a) True : compute c/b; i) Print the value of a/c; b) False: compute b*b-4*a*c; i) If ( [...]]]></description>
			<content:encoded><![CDATA[<p><strong>AIM: 	</strong><br />
	A program to solve a quadratic equation, using OOP techniques.</p>
<p><strong>ALGORITHM: </strong></p>
<p>1)	Start the process<br />
2)	Invoke the classes<br />
3)	Get the input for a,b,c;<br />
4)	Call the function getinfo() and display()<br />
5)	Check if a=0<br />
a)	True : compute c/b;<br />
i)	Print the value of a/c;<br />
b)	False: compute b*b-4*a*c;<br />
i)	If ( b*b-4*a*c)=0<br />
ii)	Call img();<br />
iii)	Otherwise : call real(a,b,c);<br />
6)	Stop the process</p>
<p><strong>PROGRAM:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">	<span style="color: #339900;">#include&lt;iostream.h&gt;</span>
	<span style="color: #339900;">#include&lt;conio.h&gt;</span>
		<span style="color: #0000ff;">class</span> equation
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span><span style="color: #0000ff;">float</span> a,b,c<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span> <span style="color: #0000ff;">void</span> getinfo<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span>  a, <span style="color: #0000ff;">float</span> b,<span style="color: #0000ff;">float</span> c <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">void</span> display<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">void</span> equal<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span>  a, <span style="color: #0000ff;">float</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">void</span> imag<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">void</span> real<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> a,<span style="color: #0000ff;">float</span> b,<span style="color: #0000ff;">float</span> c<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span>  equation <span style="color: #008080;">::</span> <span style="color: #007788;">getinfo</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> aa,<span style="color: #0000ff;">float</span> bb,<span style="color: #0000ff;">float</span> cc<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
	                a<span style="color: #000080;">=</span>aa<span style="color: #008080;">;</span>
			b<span style="color: #000080;">=</span>bb<span style="color: #008080;">;</span>
		        c<span style="color: #000080;">=</span>cc<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">void</span> equation<span style="color: #008080;">::</span><span style="color: #007788;">display</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”a<span style="color: #000080;">=</span>”<span style="color: #000080;">&lt;&lt;</span>a<span style="color: #000080;">&lt;&lt;</span>’\t’<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”b<span style="color: #000080;">=</span>”<span style="color: #000080;">&lt;&lt;</span>b<span style="color: #000080;">&lt;&lt;</span>’\t’<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”c<span style="color: #000080;">=</span>”<span style="color: #000080;">&lt;&lt;</span>c<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>		
&nbsp;
<span style="color: #0000ff;">void</span> equation <span style="color: #008080;">::</span><span style="color: #007788;">equal</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> a,<span style="color: #0000ff;">float</span> b<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">float</span> x<span style="color: #008080;">;</span>
			x <span style="color: #000080;">=</span> <span style="color: #000040;">-</span>b<span style="color: #000040;">/</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>a<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”Roots are equal “<span style="color: #000080;">&lt;&lt;</span>x<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">void</span> equation <span style="color: #008080;">::</span> <span style="color: #007788;">imag</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”Roots are imaginary”<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">void</span> equation <span style="color: #008080;">::</span> <span style="color: #007788;">real</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> a,<span style="color: #0000ff;">float</span> b,<span style="color: #0000ff;">float</span> det<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">float</span> x1,x2,temp<span style="color: #008080;">;</span>
			temp <span style="color: #000080;">=</span> <span style="color: #0000dd;">sqrt</span><span style="color: #008000;">&#40;</span>det<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			x1<span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>b <span style="color: #000040;">+</span> temp<span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>a<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			x2 <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">-</span>b –temp<span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #000040;">*</span>a<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”Roots are real”<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”x1<span style="color: #000080;">=</span> “<span style="color: #000080;">&lt;&lt;</span>x1<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”x2 <span style="color: #000080;">=</span>”<span style="color: #000080;">&lt;&lt;</span>x2<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">class</span> equation e<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">float</span> aa,bb,cc<span style="color: #008080;">;</span>
			clrscr<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>”Enter the three numbers”<span style="color: #008080;">;</span>
			<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>aa<span style="color: #000080;">&gt;&gt;</span>bb<span style="color: #000080;">&gt;&gt;</span>cc<span style="color: #008080;">;</span>
			e.<span style="color: #007788;">getinfo</span><span style="color: #008000;">&#40;</span>aa,bb,cc<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			e.<span style="color: #007788;">display</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>aa <span style="color: #000080;">=</span> <span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
			<span style="color: #008000;">&#123;</span>
				<span style="color: #0000ff;">float</span> temp<span style="color: #008080;">;</span>
				temp <span style="color: #000080;">=</span> cc<span style="color: #000040;">/</span>bb<span style="color: #008080;">;</span>
				<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>” Linear Roots”<span style="color: #000080;">&lt;&lt;</span>temp<span style="color: #000080;">&lt;&lt;</span>endl<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #0000ff;">else</span>
			<span style="color: #008000;">&#123;</span>
				<span style="color: #0000ff;">float</span> det<span style="color: #008080;">;</span>
				det <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>bb<span style="color: #000040;">*</span>bb – <span style="color: #0000dd;">4</span><span style="color: #000040;">*</span>aa<span style="color: #000040;">*</span>cc<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>det <span style="color: #000080;">=</span> <span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
				e.<span style="color: #007788;">equal</span><span style="color: #008000;">&#40;</span>aa,bb<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>det<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span>
				          e.<span style="color: #007788;">imag</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">else</span> 
				          e.<span style="color: #007788;">real</span><span style="color: #008000;">&#40;</span>aa,bb,cc <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			getch<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>OUTPUT:</strong><br />
	Enter the three numbers 2 4 1<br />
	Roots are imaginary<br />
	X1= &#8211; 0.292893<br />
	X2= &#8211; 1.707107</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-advanced-programs/c-program-for-implementation-of-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

