#include <stdio.h>
#include<math.h>
int main() {
int a, b, order;
char choice ;
printf("Enter : \n A = for arithmetic operations. \n N = for exponents of a number. \n D = for Area/Volume of 2 and 3-Dimentional figures. \n C = for Condition checking(greater/or smaller and for to check Even/or odd . \n: ");
scanf("%c", &choice);
if (choice == 'A' ) {
printf("Enter a numbers a:\n");
scanf("%d", &a);
printf("Enter a numbers b:\n");
scanf("%d", &b);
printf("Enter 1 for operations from a to b or 2 for operations from b to a: ");
scanf("%d", &order);
if (order == 1 ) {
int sum = a + b;
int difference = a - b;
int product = a * b;
float quotient = (float)a / b; // Cast to float for potential division by 0
printf("Results (a to b):\n");
printf("Sum: %d\n", sum);
printf("Difference: %d\n", difference);
printf("Product: %d\n", product);
printf("Quotient: %.2f\n", quotient); // Format quotient with 2 decimal places
} else if (order == 2) {
int sum = b + a;
int difference = b - a;
int product = b * a;
float quotient = (float)b / a; // Cast to float for potential division by 0
printf("Results (b to a):\n");
printf("Sum: %d\n", sum);
printf("Difference: %d\n", difference);
printf("Product: %d\n", product);
printf("Quotient: %.2f\n", quotient); // Format quotient with 2 decimal places
} else {
printf("Invalid order. Please enter 1 or 2 \n");
} }
if (choice == 'N' ) {
int base, exponent, power = 1; // Initialize power to 1
printf("Enter the base number: ");
scanf("%d", &base);
printf("Enter the exponent (power): ");
scanf("%d", &exponent);
// Handle negative exponents (optional)
if (exponent < 0) {
printf("Error: Exponents cannot be negative.\n");
return 1; // Indicate error
}
// Calculate the power using a loop
for (int i = 1; i <= exponent; ++i) {
power *= base; // Multiply power by base in each iteration
}
printf("%d raised to the power of %d is %d.\n", base, exponent, power);
}
if ( choice == 'D') {
float l , b ,c , h , r , m , n , x , y , f ;
char ch ;
printf("Enter : A = for finding Area of 2D figures.\n V = for finding Volume of a 3D figures :");
scanf(" %c", &ch);
if ( ch == 'A') {
char ch;
printf(" Enter : \n k = for area of a square . \n R = for area of a Rectangle . \n p = for area of a Parallelogram .\n T = for area of a Trapezium . \n t = for area of a Triangle .\n E = for area of a Equilateral Triangle . \n P = for area of a Pentagone .\n H = for area of a Hexagone. \n O = for area of a Octagone . \n a = for area of a Annulus. \n C = for area of a Circle , \n S = for Sector area of a circle.\n s = for Segment area of a circle. \n e = for area of a Ellipse");
scanf(" %c" , &ch);
if ( ch == 'k') {
printf(" Enter the side of a square");
scanf(" %f", &l);
f = l*l ;
printf(" Area of a Square is : %f", f );
}
if ( ch == 'R') {
printf("Enter the Length of a Rectangle :");
scanf(" %f" , &l);
printf(" Enter the Breadth of a Rectangle :");
scanf(" %f" , &b);
f = l*b ;
printf(" Area of a Rectangle is : %f" , f);
}
if ( ch == 'p') {
printf("Enter the Length of a Parallelogram:");
scanf(" %f" , &l);
printf(" Enter the height of a Parallelogram :");
scanf(" %f" , &b);
f = l*b ;
printf(" Area of a Parallelogram is : %f" , f);
}
if ( ch == 'T') {
printf("Enter First parallel side of a Trapezium :");
scanf(" %f" , &l);
printf(" Enter the Second parallel side of a Trapezium :");
scanf(" %f" , &b);
printf(" Enter the Height of a Trapezium :");
scanf(" %f", &h );
f = 0.5*(l + b)*h ;
printf(" Area of a Trapezium is : %f" , f);
}
if ( ch == 't') {
printf(" Enter the Breadth of a Triangle :");
scanf(" %f ", &b);
printf(" Enter the Height of the Triangle :");
scanf(" %f", &h);
f = 0.5*(b*h) ;
printf(" Area of a Triangle is : %f" , f);
}
if ( ch == 'E') {
printf(" Enter the Side of an Equilateral Triangle :");
scanf(" %f ", &b);
f = sqrt(3.0)/4 * b * b;
printf(" Area of an Equilateral Triangle is : %f" , f);
}
if ( ch == 'P')
{
printf(" Enter the Radius enclosed under the Pentagon :");
scanf(" %f ", &b);
f = 5.0/8.0 * b * b * sqrt( 10 + 2*sqrt(5)) ;
printf(" Area of a Pentagone is : %f" , f);
}
if ( ch == 'H') {
printf(" Enter the side of a Hexagone :");
scanf(" %f", &b);
f = 1.0 * b * b * sqrt( 2 ) ;
printf(" Area of a Hexagone is : %f", f);
}
if ( ch == 'O') {
printf("Enter the side of a Octagone :");
scanf(" %f", &b);
f = 6.64*b ;
printf("Area of a Octagone is : %f", f);
}
if ( ch == 'C') {
printf(" Enter the Radius of a Circle :");
scanf(" %f", &b);
f = M_PI * b * b ;
printf(" Area of a Circle is : %f", f);
}
if ( ch == 'a') {
printf(" Enter the minor diameter is a CIrcle :");
scanf(" %f", &b);
printf(" Enter the major diameter of a Circle :");
scanf(" %f", &l);
f = M_PI/4.0 *b*b*l*l ;
printf(" Area of a Annulus is : %f" , f);
}
if ( ch == 'S') {
printf(" Enter the radius of a sector :");
scanf(" %f", &b );
printf(" Enter the arc of a sector :");
scanf(" %f" , &l);
f = 0.5 * l * b ;
printf(" Area of a sector is : %f", f);
}
if ( ch == 's') {
double angle_degrees, sin_value;
printf(" Enter the segment radius :");
scanf(" %f", &b);
// Prompt user to enter angle in degrees
printf("Enter the angle in degrees (0 to 360): ");
scanf("%lf", &angle_degrees);
// Calculate sine value
sin_value = sin(angle_degrees * M_PI / 180.0); // Convert degrees to radians
f = 0.5 * ( (angle_degrees * M_PI / 180.0) - sin_value ) *b*b ;
}
if ( ch == 'e') {
printf(" Enter the major axis radius of an Ellipse :");
scanf( " %f " , &b);
printf(" Enter the minor axis radius of the Ellipse :");l
scanf(" %f", &l);
f = M_PI * b * l ;
printf(" Area of an Ellipse is : %f", f);
}
}
if ( ch == 'V') {
float a , b , c , l , b , h , f , c ;
int chh ;
printf("Enter: \n");
printf("1 = for finding Volume of a Cube.\n");
printf("2 = for finding Volume of a Cuboid.\n");
printf("3 = for finding Volume of a Parallelepiped.\n");
printf("4 = for finding Volume of a Pyramid.\n");
printf("5 = for finding Volume of a Frustum of Pyramid.\n");
printf("6 = for finding Volume of a Cylinder.\n");
printf("7 = for finding Volume of a Hollow Cylinder.\n");
printf("8 = for finding Volume of a Cone.\n");
printf("9 = for finding Volume of a Frustum of a Cone.\n");
printf("10 = for finding Volume of a Barrel.\n");
printf("11 = for finding Volume of a Sphere.\n");
printf("12 = for finding Volume of a Zone of a Sphere.\n");
printf("13 = for finding Volume of a Segment of a Sphere.\n");
printf("14 = for finding Volume of a Sector of a Sphere.\n");
printf("15 = for finding Volume of a Sphere with Cylinder.\n");
printf("16 = for finding Volume of a Sphere with Two Cones.\n");
printf("17 = for finding Volume of a Sliced Cylinder.\n");
printf("18 = for finding Volume of an Ungulla. \n");
scanf("%d", &chh);
if ( chh == 1) {
printf(" Enter the Side of the Cube :");
scanf("%f", &a);
f = a*a*a ;
printf(" Volume is : %f", f);
}
if ( chh == 2) {
printf(" Enter the Length of a Cuboid :");
scanf(" %f", &l);
printf(" Enter the Breadth of the Cuboid :");
scanf(" %f", &b);
printf(" Enter the Height of a Cuboid :");
scanf(" %f", &h);
f = l*b*h ;
printf("Volume of a Cuboid : %f", f);
}
if ( chh == 4) {
printf(" Enter the Base Length of a Pyramid :");
scanf(" %f", &l);
printf(" Enter the Base Width of a Pyramid :");
scanf(" %f", &b);
printf(" Enter the Height of a Pyramid:");
scanf(" %f", &h);
f = 1.0/3.0 * (l*b*h) ;
printf(" Volume of a Pyramid is : %f " ,f);
}
if ( chh == 5) {
printf(" Enter the Base Length of a Frustum of Pyramid :");
scanf(" %f", &l);
printf(" Enter the Base Width of Frustum of Pyramid :");
scanf(" %f", &b);
printf(" Enter the smaller Base Length of a Frustum of Pyramid :");
scanf(" %f", &a);
printf(" Enter the Smaller Base Width of Frustum of Pyramid :");
scanf(" %f", &c);
printf(" Enter the Height of a Pyramid Frustum:");
scanf(" %f", &h);
f =1.0/3.0 * h*( l*b*a*c + sqrt( a*b*l*c)) ;
printf( " Vloume of a Frustum of Pyramid is : %f", f);
}
if ( chh == 6) {
printf(" Enter the Diameter of a Cylinder : ");
scanf(" %f", &l);
printf(" Enter the Height of a Cylinder:");
scanf(" %f", &h);
f = 1.0/4.0 * M_PI * l*l * h ;
printf(" Volume of a Cylinder is : %f ", f);
}
if ( chh == 7) {
printf(" Enter the Bigger Diameter of a Hollow Cylinder : ");
scanf(" %f", &l);
printf(" Enter the Smaller Diameter of a Hollow Cylinder : ");
scanf(" %f", &a);
printf(" Enter the Height of a Cylinder:");
scanf(" %f", &h);
f = 1.0/4.0 * M_PI * ( l*l - a*a);
printf(" Volume of a Hollow Cylinder is : %f ", f);
}
if ( chh == 8) {
printf(" Enter the Radius of a Cone : ");
scanf(" %f", &l);
printf(" Enter the Height of a Cylinder:");
scanf(" %f", &h);
f = 1.0/3.0 * M_PI * l*l*h ;
printf("Volume of a cone is : %f", f);
} if ( chh == 3) {
printf(" Enter the Length of a Parallelepiped:");
scanf(" %f", &l);
printf(" Enter the Breadth of the Parallelepiped:");
scanf(" %f", &b);
printf(" Enter the Height of a Parallelepiped :");
scanf(" %f", &h);
f = l*b*h ;
printf("Volume of a Parallelepiped : %f", f);
} if ( chh == 9) {
printf(" Enter the Larger Diameter of a Frustum of a Cone : ");
scanf(" %f", &l);
printf(" Enter the Smaller Diameter of a Frustum of a Cone : ");
scanf(" %f", &b);
printf(" Enter the Height of a Cylinder:");
scanf(" %f", &h);
f = h*M_PI * ( l*l + l*b + b*b) * 1.0/12.0 ;
printf(" Volume of a Frustum of Cone is : %f", f);
} if ( chh == 10) {
printf(" Enter the Larger Diameter of a Barrel: ");
scanf(" %f", &l);
printf(" Enter the Smaller Diameter of a Barrel : ");
scanf(" %f", &b);
printf(" Enter the Height of a Barrel:");
scanf(" %f", &h);
f = M_PI * h * ( 2*l*l + b*b ) * 1.0/ 12.0 ;
printf(" Volume of a Barrel is : %f", f);
} if ( chh == 11) {
printf(" Enter the Diameter of the Sphere :");
scanf("%f", &l);
f = M_PI * l*l*l * 1.0/6.0 ;
printf(" Volume of a Sphere is : %f", f);
} if ( chh == 12) {
printf(" Enter the Bigger Radius of Zone of the Sphere :");
scanf("%f", &l);
printf(" Enter the Smaller Radius of Zone of the Sphere :");
scanf("%f", &b);
printf(" Enter the Height of a Zone of a Sphere:");
scanf(" %f", &h);
f = M_PI * h * ( 3*l*l + 3*b*b + h*h);
printf("Volume of a Zone of a Sphere is : %f", f);
} if ( chh == 13) {
printf(" Enter the Diameter of a Segment of a Sphere :");
scanf("%f", &l);
printf(" Enter the Height of a Segment of a Sphere :");
scanf("%f", &b);
f = M_PI * h * ( 3.0/4.0 * l*l + h*h);
printf(" Vomume of a Segment of a Sphere is : %f", f);
} if ( chh == 14) {
printf(" Enter Radius of a Sector Sphere :");
scanf("%f", &l);
printf(" Enter the Height of the Sector of a sphere:");
scanf("%f", &b);
f = 2.0/3.0 * M_PI * l*l * b ;
printf(" Volume of a sector of a Sphere is : %f", f);
} if ( chh == 15) {
printf(" Enter the Height of a Sphere with a Cylinder:");
scanf("%f", &l);
f = 1.0/6.0 * l*l*l ;
printf(" VOlume of a Sphere with a Cylinder is : %f", f);
} if ( chh == 16) {
printf(" :");
scanf("%f", &l);
printf(" Enter the Smaller Radius of Zone of the Sphere :");
scanf("%f", &b);
} if ( chh == 17) {
printf(" Enter the Diameter of a Sliced Cylinder:");
scanf(" %f ", &l);
printf(" Enter the Height of a Sliced Cylinder :");
scanf(" %f ", &b);
f = M_PI * 1.0/4.0 * l*l * b ;
printf(" Volume of a Sliced Cylinder is : %f", f);
} if ( chh == 18) {
printf(" Enter Radius of an Ungulla :");
scanf(" %f", &l);
printf(" Enter the height of an Ungulla :");
scanf(" %f", &b);
f = 2.0/3.0 * l*l * b ;
printf(" Volume of an Ungulla :%f", f);
} }
}
if ( choice == 'C' ) {
}
return 0 ;
}