C Program To Find Roots of The Quadratic Equation: Z X +3) X y 4) (Y +5)
C Program To Find Roots of The Quadratic Equation: Z X +3) X y 4) (Y +5)
C Program To Find Roots of The Quadratic Equation: Z X +3) X y 4) (Y +5)
#include <stdio.h>
#include <conio.h>
#include <Math.h>
void main ()
{
float a,b,c,r1,r2;
clrscr();
printf("Enter the coefficients of equations");
scanf("%f %f %f",&a,&b,&c);
r1=(-b+sqrt(b*b-4*a*c))/(2*a);
r2=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("\nThe roots of the equation are % f and %f ",r1,r2);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,y,z;
clrscr();
printf("\n Enter values for x and y: ");
scanf("%f %f",&x,&y);
z=((x+3)*x*x*x)/((y-4)(y+5));
printf("\n Value of the expression Z=((x+3)*x*x*x)/((y-4)(y+5)): %f",z);
getch();
}
2 v +6.22(c+ d)
(b) R=
g+ v
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float c,d,g,v,r;
clrscr();
printf("\n Enter values for c,d,g and v: ");
scanf("%f %f %f %f",&c,&d,&g,&v);
r=((2*v)+(6.22*(c+d)))/(g+v);
printf("\n Value for the expression R=((2*v)+(6.22(c+d)))/(g+v):
%f",r);
getch();
}
7.7 b ( xy +a )
−0.8+ 2b
c
(c) A=
1
(x+ a)( )
y
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,x,y,A=0;
clrscr();
printf("\n Enter values for a,b,c,x and y: ");
scanf("%f %f %f %f",&a,&b,&c,&x,&y);
A=(((7.7*b*((x*y)+a))/c)-(0.8+(2*b)))/((x+a)*(1/y));
printf("\n Value of expression \n
A=(((7.7*b*((x*y)+a))/c)-(0.8+(2*b)))/((x+a)*(1/y)): %f",A);
getch();
}
y
Hint: r =√( x + y )∧φ=tan
2 2 −1
x
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
float x,y,a,b;
clrscr();
a=sqrt((x*x)+(y*y));
b=atan(y/x);
printf("\n Polar coordinates are: %f and %f",a,b);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
char a;
printf("Enter a character ");
scanf("%c", &a);
printf("ASCII value of %c is %d \n ",a ,a);
getch();
}
Write a program to convert lowercase to uppercase
letter using if-else
#include <stdio.h>
#include <conio.h>
void main()
{
char c,ch;
clrscr();
printf("Enter a letter ");
scanf("%c",&c);
if(c>=97 && c<=122)
{
ch=c-32;
printf("The uppercase of %c is %c ",c,ch);
}
else
{
printf("The letter itself is in upper case ");
}
getch();
}
WAP to check whether a number is divisible by 3 and
5 or by 3 or 5.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,flag=0;
clrscr();
printf("Enter a number: \n");
scanf("%d",&n);
if(n%3==0)
flag+=1;
if(n%5==0)
flag+=2;
if(flag==3)
printf("Divisible by both 3 and 5\n");
else if(flag==1)
printf("Only divisible by 3\n");
else if (flag==2)
printf("Only divisible by 5\n");
else
printf("Divisible by none(i.e. 3 and 5)\n");
getch();
}
WAP to enter the marks of a student in 4 subjects.
Calculate total ,aggregate and display the grades.
#include <stdio.h>
#include <conio.h>
void main()
{
float a,b,c,d,t,avg;
clrscr();
printf("Enter the marks in 4 subjects ");
scanf("%f %f %f %f",&a,&b,&c,&d);
t=(a+b+c+d);
avg=((t)/4);
printf("\nTotal marks obtained by the student is %f",t);
printf("\nAverage marks obtained by the student is %f",avg);
printf("\nPercentage obtained by the student is %f",avg);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
float sal,gsal,hra,da;
clrscr();
printf("Enter the salary of the employee \t");
scanf("%f",&sal);
if(sal>=1 && sal <=4000)
{
hra=sal*0.1;
da=0.50*sal;
}
else if(sal>=4001 && sal<=8000)
{
hra=0.20*sal;
da=sal*0.60;
}
else if(sal>=8001 && sal<=12000)
{
hra=0.25*sal;
da=0.70*sal;
}
else
{
hra=0.30*sal;
da=0.80*sal;
}
gsal=sal+hra+da;
printf("The salary is %f \n",sal);
printf("The HRA is %f \n",hra);
printf("The DA is %f \n",da);
printf("The gross salary is %f \n",gsal);
getch();
}
Write a C program to input electricity unit charge
and calculate the total electricity bill according to
the given condition:
#include <stdio.h>
#include <conio.h>
void main()
{
float unit,bill,total;
bill=0;
clrscr();
printf("Enter electricity unit ");
scanf("%f", &unit);
if(unit<=50)
{
bill=unit*0.50;
}
else if(unit<=150)
{
bill=(50)*0.50+(unit-50)*0.75;
}
else if(unit<=250)
{
bill=50*0.50+100*0.75+(unit -150)*1.20;
}
else
{
bill=50*0.50+100*0.75+100*1.20+(unit-250)*1.50;
}
total=bill+0.20*bill;
printf("The electricity bill for %f unit is %f ",unit,total);
getch();
}