"C' Examples C

Program to read the values for coefficients a,b and c of a quadratic equation ax²+bx+c=0.

Problem Analysis:

The problem is to read the values of coefficient a,b,c of quadratic equation ax²+bx+c=0 and to find the equation of the roots.

i.e. r1 =(-b + sqrt (d) /(2*a);                                            d=(b*b)-(4*a*c);

r2=(-b- sqrt   (d)/(2*a);

Input variables          Processing variables      Output variables          Necessary header files

a(int)                             r1=(-b+sqrt(d)/(2*a);      r1(float)                         stdio.h

b(int)                             r2=(-b-sqrt(d)/(2*a);       r2(float)                         conio.h

c(int)                             d=(b*b) – (4*a*c);                                                 math.h







2.Define : a,b,c.d,r1(float),r2(float).

3.Input : a,b,c from the user.

4. Calculate:

d=(b*b) -(4*a*c)

if (a>c),r1=(-b+sqrt(d)/(2*a);


5.print the result as r1/r2 else the root is imaginary if d<0.





Compiling  , Debugging and  Testings

Enter  a   b  c:  100  300  200

answer=-1   answer  =-2

We the teams of programming faster managed to provide an effective information about the codes of different programming languages.Hope you will learn and understand the codes fast and easy. It's absolutely free, expanding and precise. Our main target is to help those new starters and aid them as far as possible to pave their future in the area of programming. Hoping support and recommendations!

Related Posts

HTML color code

HTML (Hypertext Markup Language) is a standard markup language that is used for creating and structuring web pages. HTML provides a set of elements and tags that define…

C program to add two numbers and display sum in the screen

CODES:   OUTPUTS: enter values of a and b: 2 3 the sum is 5.00

C program to read a character from user and display it ASCII value

CODES:   CODES: enter a character: B the ASCII value of character B is 66

C program to read three sides of a triangle and calculate the area

CODES:   OUTPUTS: enter three sides of triangle a,b,c:3 4 5 the area of the triangle is :6.00

C program to read height and base of a triangle and find the area of it

CODES: OUTPUTS: enter the height of triangle:5 enter the base of triangle :3.5 the area of the triangle is:8.75

C program to calculate the area and perimeter of rectangle

CODES: OUTPUTS: enter the length and breadth of a rectangle :2.5  1.5 the area of rectangle is :3.750000 the perimeter of rectangle is :8.000000

Leave a Reply

Your email address will not be published. Required fields are marked *