Skip to main content

Posts

Showing posts from June, 2016

WAP to enter three sides of triangle and find area.

// WAP to enter three sides of triangle and find area.     #include<stdio.h> #include<conio.h> #include<math.h> void main ( ) { float a , b , c , s , a = 0 ; clrscr ( ) ; printf ( "Enter three length of triangle: \n " ) ; scanf ( "%f%f%f" ,& a ,& b ,& c ) ; s = ( a + b + c ) / 2 ; a = sqrt ( s * ( s - a ) * ( s - b ) * ( s - c ) ) ; printf ( "Area of triangle is %f" , a ) ; getch ( ) ; }  

WAP to enter three coefficient of quadratic equation and find the roots.

// WAP to enter three coefficient of quadratic equation and find the roots.     #include<stdio.h> #include<conio.h> #include<math.h> void main ( ) { float a , b , c , d , x1 = 0 , x2 = 0 ; clrscr ( ) ; printf ( "Enter coefficient of x 2 : \n " ) ; scanf ( "%f" ,& a ) ; printf ( "Enter coefficient of x: \n " ) ; scanf ( "%f" ,& b ) ; printf ( "Enter constant: \n " ) ; scanf ( "%f" ,& c ) ; d = ( b * b - 4 * a * c ) ; x1 = ( - b + sqrt ( d ) ) / ( 2 * a ) ; x2 = ( - b - sqrt ( d ) ) / ( 2 * a ) ; printf ( "x1 = %f \n " , x1 ) ; printf ( "x2 = %f \n " , x2 ) ; getch ( ) ; }  

Write a program to enter mark of 5 subjects & calculate total mark and percentage.

// Write a program to enter mark of 5 subjects & calculate total mark and percentage.     #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c , d , e ; float per , total = 0 ; clrscr ( ) ; printf ( "Enter marks of five subject: \n " ) ; scanf ( "%d%d%d%d%d" ,& a ,& b ,& c ,& d ,& e ) ; total = a + b + c + d + e ; per = total / 5 ; printf ( "Total marks = %f" , total ) ; printf ( "Total percentage = %f" , per ) ; getch ( ) ; }  

Write a program to enter three number & calculate sum and product.

// Write a program to enter three number & calculate sum and product.     #include<stdio.h> #include<conio.h> void main ( ) { int x , y , z , sum = 0 , mult = 1 ; clrscr ( ) ; printf ( "Enter three numbers: \n " ) ; scanf ( "%d%d%d" ,& x ,& y ,& z ) ; sum = x + y + z ; mult = x * y * z ; printf ( "Sum = %d" , sum ) ; printf ( "Product = %d" , mult ) ; getch ( ) ; }  

Write a program to calculate Simple interest by entering value of principle, time and rate.

// Write a program to calculate Simple interest by entering value of principle, time and rate.     #include<stdio.h> #include<conio.h> void main ( ) { float p , t , r , si = 0 ; clrscr ( ) ; printf ( "Enter value of principle, time and rate: \n " ) ; scanf ( "%f%f%f" ,& p ,& t ,& r ) ; si = ( p * t * r ) / 100 ; printf ( "Simple interest = %f" , si ) ; getch ( ) ; }  

Write a program to calculate Area of circle.

// Write a program to calculate Area of circle.     #include<stdio.h> #include<conio.h> #define pi 3.14 void main ( ) { int r , area = 0 ; clrscr ( ) ; printf ( "Enter radius of circle: \n " ) ; scanf ( "%d" ,& r ) ; area = pi * r * r ; printf ( "Area of circle is %d" , area ) ; getch ( ) ; }