saving . . . saved write a c program to find the roots of a quadratic equation has been deleted. write a c program to find the roots of a quadratic equation has been hidden .
write a c program to find the roots of a quadratic equation
Title
Question
write a c program to find the roots of a quadratic equation

C-and-Cpp If-And-Else-If-statement 02-03 min 10-20 sec 25-07-18, 11:58 a.m. santhoshkasalaniit

Answers:

<ol class="linenums" style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; list-style: none; padding: 7.29688px; color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 14px; white-space: pre;"><li class="L0" style="list-style-type: none;"><span class="com" style="color: rgb(136, 0, 0);">#include</span><span class="str" style="color: rgb(0, 136, 0);"><stdio.h></span></li><li class="L1" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="com" style="color: rgb(136, 0, 0);">#include</span><span class="str" style="color: rgb(0, 136, 0);"><math.h></span></li><li class="L3" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="kwd" style="color: rgb(0, 0, 136);">int</span><span class="pln" style="color: rgb(0, 0, 0);"> main</span><span class="pun" style="color: rgb(102, 102, 0);">()</span></li><li class="L3" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pun" style="color: rgb(102, 102, 0);">{</span></li><li class="L4"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">float</span><span class="pln" style="color: rgb(0, 0, 0);"> a</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">b</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">c</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L5" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">float</span><span class="pln" style="color: rgb(0, 0, 0);"> d</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">root1</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">root2</span><span class="pun" style="color: rgb(102, 102, 0);">;</span><span class="pln" style="color: rgb(0, 0, 0);"> </span></li><li class="L8" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Enter a, b and c of quadratic equation: "</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L9" style="background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> scanf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"%f%f%f"</span><span class="pun" style="color: rgb(102, 102, 0);">,&</span><span class="pln" style="color: rgb(0, 0, 0);">a</span><span class="pun" style="color: rgb(102, 102, 0);">,&</span><span class="pln" style="color: rgb(0, 0, 0);">b</span><span class="pun" style="color: rgb(102, 102, 0);">,&</span><span class="pln" style="color: rgb(0, 0, 0);">c</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L1" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> d </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> b </span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> b </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">4</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> a </span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> c</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L3" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">if</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">d </span><span class="pun" style="color: rgb(102, 102, 0);"><</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">){</span></li><li class="L4"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Roots are complex number.\\n"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Roots of quadratic equation are: "</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L7" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"%.3f%+.3fi"</span><span class="pun" style="color: rgb(102, 102, 0);">,-</span><span class="pln" style="color: rgb(0, 0, 0);">b</span><span class="pun" style="color: rgb(102, 102, 0);">/(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);">a</span><span class="pun" style="color: rgb(102, 102, 0);">),</span><span class="pln" style="color: rgb(0, 0, 0);">sqrt</span><span class="pun" style="color: rgb(102, 102, 0);">(-</span><span class="pln" style="color: rgb(0, 0, 0);">d</span><span class="pun" style="color: rgb(102, 102, 0);">)/(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);">a</span><span class="pun" style="color: rgb(102, 102, 0);">));</span></li><li class="L8" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">", %.3f%+.3fi"</span><span class="pun" style="color: rgb(102, 102, 0);">,-</span><span class="pln" style="color: rgb(0, 0, 0);">b</span><span class="pun" style="color: rgb(102, 102, 0);">/(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);">a</span><span class="pun" style="color: rgb(102, 102, 0);">),-</span><span class="pln" style="color: rgb(0, 0, 0);">sqrt</span><span class="pun" style="color: rgb(102, 102, 0);">(-</span><span class="pln" style="color: rgb(0, 0, 0);">d</span><span class="pun" style="color: rgb(102, 102, 0);">)/(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);">a</span><span class="pun" style="color: rgb(102, 102, 0);">));</span></li><li class="L0" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">;</span><span class="pln" style="color: rgb(0, 0, 0);"> </span></li><li class="L1" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L2" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">else</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">if</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">d</span><span class="pun" style="color: rgb(102, 102, 0);">==</span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">){</span></li><li class="L3" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Both roots are equal.\\n"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L5" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> root1 </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);">b </span><span class="pun" style="color: rgb(102, 102, 0);">/(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> a</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Root of quadratic equation is: %.3f "</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">root1</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L8" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L9" style="background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L0" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">else</span></li><li class="L0" style="list-style-type: none;"><span class="pun" style="color: rgb(102, 102, 0);"> {</span></li><li class="L1" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Roots are real numbers.\\n"</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L3" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> root1 </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);">b </span><span class="pun" style="color: rgb(102, 102, 0);">+</span><span class="pln" style="color: rgb(0, 0, 0);"> sqrt</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">d</span><span class="pun" style="color: rgb(102, 102, 0);">))</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">/</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> a</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L4"><span class="pln" style="color: rgb(0, 0, 0);"> root2 </span><span class="pun" style="color: rgb(102, 102, 0);">=</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);">b </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);"> sqrt</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">d</span><span class="pun" style="color: rgb(102, 102, 0);">))</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">/</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="lit" style="color: rgb(0, 102, 102);">2</span><span class="pun" style="color: rgb(102, 102, 0);">*</span><span class="pln" style="color: rgb(0, 0, 0);"> a</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L5" style="list-style-type: none; background: rgba(238, 238, 238, 0.26);"><span class="pln" style="color: rgb(0, 0, 0);"> printf</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="str" style="color: rgb(0, 136, 0);">"Roots of quadratic equation are: %.3f , %.3f"</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">root1</span><span class="pun" style="color: rgb(102, 102, 0);">,</span><span class="pln" style="color: rgb(0, 0, 0);">root2</span><span class="pun" style="color: rgb(102, 102, 0);">);</span></li><li class="L6" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="pun" style="color: rgb(102, 102, 0);">}</span></li><li class="L8" style="list-style-type: none;"><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="kwd" style="color: rgb(0, 0, 136);">return</span><span class="pln" style="color: rgb(0, 0, 0);"> </span><span class="lit" style="color: rgb(0, 102, 102);">0</span><span class="pun" style="color: rgb(102, 102, 0);">;</span></li><li class="L9" style="background: rgba(238, 238, 238, 0.26);"><span class="pun" style="color: rgb(102, 102, 0);">}</span></li></ol>
13-09-18, 12:18 a.m. aashikk1902@gmail.com


Log-in to answer to this question.