C Program to Solve Second Order Quadratic Equation

C Program to Solve Second Order Quadratic Equation

Program : To obtain solution of second order quadratic equation
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c;
float desc,root1,root2;
clrscr();
printf("nEnter the Values of a : ");
scanf("%f",&a);
printf("nEnter the Values of b : ");
scanf("%f",&b);
printf("nEnter the Values of c : ");
scanf("%f",&c);

desc = sqrt(b*b-4*a*c);

root1 = (-b + desc)/(2.0*a);
root2 = (-b - desc)/(2.0*a);

printf("nFirst Root : %f",root1);
printf("nSecond Root : %f",root2);

getch();
}
Output :
Enter the Values of a : 1
Enter the Values of a : -5

Enter the Values of a : 6

First Root : 3.000000
C Program to find sum of two numbers

C Program to find sum of two numbers

Program : C Program to find sum of two numbers

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,sum;
clrscr();

printf("Enter two no: ");
scanf("%d%d",&a,&b);

sum = a+b;

printf("Sum : %d",sum);

getch();
}
Output :
Enter two no: 5 6
Sum : 11
C Program to Calculate Area and Circumference of circle

C Program to Calculate Area and Circumference of circle

C Program to find area and circumference of circle

#include<stdio.h>

int main()
{
int rad;
float PI=3.14,area,ci;

printf("nEnter radius of circle: ");
scanf("%d",&rad);

area = PI * rad * rad;
printf("nArea of circle : %f ",area);

ci = 2 * PI * rad;
printf("nCircumference : %f ",ci);

return(0);
}

Output :

Enter radius of a circle : 1
Area of circle : 3.14
Circumference  : 6.28

Explanation of Program :

In this program we have to calculate the area and circumference of the circle. We have following 2 formulas for finding circumference and area of circle.
Area of Circle = PI * R * R
and
Circumference of Circle = 2 * PI * R
In the above program we have declared the floating point variable PI whose value is defaulted to 3.14.We are accepting the radius from user.
printf("nEnter radius of circle: ");
scanf("%d",&rad);
C Program to find the simple interest

C Program to find the simple interest

C Program to find the simple interest
#include<stdio.h>
#include<conio.h>

void main()
{
int amount,rate,time,si;
clrscr();

printf("nEnter Principal Amount : ");
scanf("%d",&amount);

printf("nEnter Rate of interest : ");
scanf("%d",&rate);

printf("nEnter Period of Time   : ");
scanf("%d",&time);

si = (amount * rate * time)/100;

printf("Simple Intrest : %d",si);

getch();
}
Output :
Enter Principal Amount : 500
Enter Rate of interest : 5
Enter Period of Time   : 2
Simple Interest : 50
C Program to Convert temperature from degree centigrade to Fahrenheit

C Program to Convert temperature from degree centigrade to Fahrenheit

Program to convert temperature from degree centigrade to Fahrenheit

#include<stdio.h>
#include<conio.h>

void main()
{
float celsius,fahrenheit;
clrscr();

printf("nEnter temp in Celsius : ");
scanf("%f",&celsius);

fahrenheit = (1.8 * celsius) + 32;
printf("nTemperature in Fahrenheit : %f ",fahrenheit);

getch();
}
Output :
Enter temp in Celsius : 32
Temperature in Fahrenheit : 89.59998
C Program to calculate sum of 5 subjects and find percentage

C Program to calculate sum of 5 subjects and find percentage

C Program to calculate sum of 5 subjects and find percentage

#include<stdio.h>
#include<conio.h>

void main()
{
int s1,s2,s3,s4,s5,sum,total=500;
float per;

clrscr();

printf("nEnter marks of 5 subjects : ");
scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);

sum = s1 + s2 + s3 + s4 + s5;

printf("nSum : %d",sum);

per = (sum * 100) / total;

printf("nPercentage : %f",per);
getch();
}
Output :
Enter marks of 5 subjects : 80 70 90 80 80
Sum : 400
Percentage : 80.00