void dcmatrix_Multiply ( int n, int m, int l, dcmplx a[n][m], POLY b[m][l], POLY c[n][l] ) { int i, j, k; POLY tmp1, tmp2; zero_matrix ( n, l, c); for ( i=0; i<n; i++ ) { for ( j=0; j<l; j++ ) { for ( k=0; k<m; k++ ) { tmp1 = mul_dcmplx_poly ( a[i][k], b[k][j] ); tmp2.p=add_poly(c[i][j].d, c[i][j].p, tmp1.d, tmp1.p, &(tmp2.d)); free(c[i][j].p); c[i][j]=assign_poly(tmp2); free(tmp1.p); free(tmp2.p); /* c[i][j]+=a[i][k]*b[k][j];*/ } } } }
/* * Fill table with random polys: * - nvars = number of initial variables (must be positive) * poly[1 ... nvars] will all be variables * - n = total number of polynomials to build (including nvars) */ static void build_poly_table(poly_table_t *table, uint32_t nvars, uint32_t n) { poly_buffer_t buffer; polynomial_t *p; uint32_t i; for (i=0; i<nvars; i++) { add_poly(table, NULL); } init_poly_buffer(&buffer); while (i<n) { p = NULL; if (random_index(10) != 0) { p = random_poly(&buffer, table); } add_poly(table, p); i ++; } delete_poly_buffer(&buffer); }
int main() { nodeptr one,two,sum; int x; int y=0; float c; one=getnode(); two=getnode(); sum=getnode(); one->link=one; two->link=two; sum->link=sum; printf("1.enter first poly 2.enter second poly 3. add and display 4.exit"); while(y!=4) { printf("enter choice"); scanf("%d",&y); switch(y) { case 1: printf("enter coefficient of x"); scanf("%f",&c); printf("enter power of x"); scanf("%d",&x); one=create_poly(c,x,one); break; case 2: printf("enter coefficient of x"); scanf("%f",&c); printf("enter power of x"); scanf("%d",&x); two=create_poly(c,x,two); break; case 3: sum=add_poly(one,two); } } return 0; }
POLY add_poly1 ( POLY a, POLY b) { POLY c; c.p = add_poly(a.d, a.p, b.d, b.p, &(c.d)); return c; }
void manual_test ( int n, int m, int l ) { double eps = 1.0e-12; double tol = 1.0e-8; double mul_tol = 1.0e-3; dcmplx aa[n+1], bb[m+1], c[l+1], a[n+l+1], *dcmplx_a, b[m+l+1], *dcmplx_b, ra[n+l], rb[m+l], rc[l]; int i, j, c_num, bug, dk, dl, dgcd, k1, k2, dc_gcd; dcmplx **gcd_coeff; dcmplx *t1, *t2, *c_gcd; int dbd, dad, mult[l]; printf("please input the polynomial aa\n"); for(i=0; i<=n; i++) read_dcmplx( &(aa[i])); printf("please input the polynomial bb\n"); for(i=0; i<=m; i++) read_dcmplx(&(bb[i])); printf("please input the polynomial c, (the leading coefficient must be one!)\n"); for(i=0; i<=l; i++) read_dcmplx(&(c[i])); for(i=0; i<=n+l; i++) a[i]=create1(0.0); for(i=0; i<=n; i++) for(j=0; j<=l; j++) a[i+j]=add_dcmplx(a[i+j], mul_dcmplx(aa[i], c[j])); for(i=0; i<=m+l; i++) b[i]=create1(0.0); for(i=0; i<=m; i++) for(j=0; j<=l; j++) b[i+j]=add_dcmplx(b[i+j], mul_dcmplx(bb[i], c[j])); gcd( n+l+1, a, m+l+1, b, &c_num, ra, rb ); printf("the roots number of the given common diviser is: %d \n", l); multiple_roots(l+1, c, eps, 10*l, rc, mul_tol, mult); printf("the root of the gcd is:\n"); for(i=0; i<l; i++) writeln_dcmplx(rc[i]); printf("the roots number of the calculated common diviser is: %d \n", c_num); if(l!= c_num) { printf("Bug!!\n"); exit(1); } for(i=0; i<l; i++) { bug=1; for(j=0; j<l; j++) { if(equal_dcmplx(rc[i], ra[j], tol)) bug=0; } if( bug==1 ) { printf(" Bug!!\n"); exit(1); } } printf("the gcd is correct !\n"); /* now begin to test extended gcd method */ gcd_coeff=ExtPolyGcd( n+l+1, a, m+l+1, b, &dgcd, &dk, &dl, &dbd, &dad); Print_Poly(dl, gcd_coeff[1]); printf("a is:\n"); Print_Poly(n+l, a); dcmplx_a=(dcmplx*) calloc(n+l+1, sizeof(dcmplx)); /* for(i=0; i<=n+l; i++) dcmplx_a[i]=a[i]; */ t1=mul_poly( dk, gcd_coeff[0], n+l, a, &k1 ); t2=mul_poly( dl, gcd_coeff[1], m+l, b, &k2 ); /* printf("t1 is:\n"); for(i=0; i<=k1; i++) writeln_dcmplx(t1[i]); printf("t2 is:\n"); printf("dl=%d\n", dl); printf("m+l=%d\n", m+l); for(i=0; i<=k2; i++) writeln_dcmplx(t2[i]); */ printf("\n"); printf("k is:\n"); for(i=0; i<=dk; i++) writeln_dcmplx(gcd_coeff[0][i]); printf("l is:\n"); for(i=0; i<=dl; i++) writeln_dcmplx(gcd_coeff[1][i]); printf("\n"); c_gcd=add_poly( k1, t1, k2, t2, &dc_gcd); printf("the given polynomial a is:\n"); for(i=0; i<=n+l; i++) writeln_dcmplx(a[i]); printf("a's roots are:\n"); for(i=0; i<n+l; i++) writeln_dcmplx(ra[i]); printf("\n"); printf("the given polynomial b is:\n"); for(i=0; i<=m+l; i++) writeln_dcmplx(b[i]); printf("b's roots are:\n"); for(i=0; i<m+l; i++) writeln_dcmplx(rb[i]); printf("\n"); printf("the given gcd polynomial is:\n"); for(i=0; i<=l; i++) writeln_dcmplx(c[i]); printf("\n"); if(l!= dc_gcd) { printf("Bug!! the given gcd is different with the gcd method result.(0 is special case).\n"); } printf("the calculated gcd polynomial is:\n"); for(i=0; i<=dc_gcd; i++) writeln_dcmplx(c_gcd[i]); printf("\n"); printf("the gcd from common roots method is:\n"); for(i=0; i<=dgcd; i++) writeln_dcmplx(gcd_coeff[2][i]); printf("\n"); free(t1); free(t2); free(c_gcd); free(gcd_coeff[0]); free(gcd_coeff[1]); free(gcd_coeff[2]); free(gcd_coeff[3]); free(gcd_coeff[4]); free(gcd_coeff); }
void random_test ( int n, int m, int l ) { double eps = 1.0e-12; double tol = 1.0e-8; double mul_tol = 1.0e-3; dcmplx aa[n+1], bb[m+1], c[l+1], a[n+l+1], b[m+l+1], ra[n+l], rb[m+l], rc[l]; int i, j, c_num, bug, dk, dl, dgcd, k1, k2, dc_gcd; dcmplx **gcd_coeff; dcmplx *t1, *t2, *c_gcd; dcmplx near; double error=1.0; int dbd, dad, mult[l]; srand(time(NULL)); for(i=0; i<=n; i++) aa[i] = random_dcmplx1(); for(i=0; i<=m; i++) bb[i] = random_dcmplx1(); c[l]=create1(1.0); for(i=0; i<l; i++) c[i] = random_dcmplx1(); for(i=0; i<=n+l; i++) a[i]=create1(0.0); for(i=0; i<=n; i++) for(j=0; j<=l; j++) a[i+j]=add_dcmplx(a[i+j], mul_dcmplx(aa[i], c[j])); for(i=0; i<=m+l; i++) b[i]=create1(0.0); for(i=0; i<=m; i++) for(j=0; j<=l; j++) b[i+j]=add_dcmplx(b[i+j], mul_dcmplx(bb[i], c[j])); gcd( n+l+1, a, m+l+1, b, &c_num, ra, rb ); printf("the roots number of the given common diviser is: %d \n", l); multiple_roots(l+1, c, eps, 10*l, rc, mul_tol, mult); /* printf(" the root of the gcd is:\n"); for(i=0; i<l; i++) writeln_dcmplx(rc[i]); printf("\n"); */ printf("the roots number of the calculated common diviser is: %d \n", c_num); if(l!= c_num) { printf("Bug!!\n"); printf("a is:\n"); for(i=0; i<=n+l; i++) writeln_dcmplx(a[i]); printf("b is:\n"); for(i=0; i<=m+l; i++) writeln_dcmplx(b[i]); printf("a's roots are:\n"); for(i=0; i<n+l; i++) writeln_dcmplx(ra[i]); printf("b's roots are:\n"); for(i=0; i<m+l; i++) writeln_dcmplx(rb[i]); printf("fail reason: gcd roots number is not correct.\n"); exit(1); } for(i=0; i<l; i++) { bug=1; for(j=0; j<l; j++) { if(equal_dcmplx(rc[i], ra[j], tol)) bug=0; if(dcabs(sub_dcmplx(rc[i], ra[j]))<error) { error=dcabs(sub_dcmplx(rc[i], ra[j])); near=ra[j]; } } if( bug==1 ) { printf("a is:\n"); for(i=0; i<=n+l; i++) writeln_dcmplx(a[i]); printf("b is:\n"); for(i=0; i<=m+l; i++) writeln_dcmplx(b[i]); printf("a's roots are:\n"); for(i=0; i<n+l; i++) writeln_dcmplx(ra[i]); printf("b's roots are:\n"); for(i=0; i<m+l; i++) writeln_dcmplx(rb[i]); printf("the given common root is:"); writeln_dcmplx(rc[i]); printf("the nearest one to the given common roots is:"); writeln_dcmplx(near); printf("the difference is:%lf\n", error); printf("fail reason: the common root is not the given gcd root\n"); printf(" Bug!!\n"); exit(1); } } printf("the result is correct !\n"); /* now begin to test extended gcd method */ gcd_coeff=ExtPolyGcd( n+l+1, a, m+l+1, b, &dgcd, &dk, &dl, &dbd, &dad); t1=mul_poly( dk, gcd_coeff[0], n+l, a, &k1 ); t2=mul_poly( dl, gcd_coeff[1], m+l, b, &k2 ); c_gcd=add_poly( k1, t1, k2, t2, &dc_gcd); /* printf("the given polynomial a is:\n"); for(i=0; i<=n+l; i++) writeln_dcmplx(a[i]); printf("\n"); printf("the given polynomial b is:\n"); for(i=0; i<=m+l; i++) writeln_dcmplx(b[i]); printf("\n"); */ printf("the given gcd polynomial is:\n"); for(i=0; i<=l; i++) writeln_dcmplx(c[i]); printf("\n"); printf("the calculated gcd polynomial is:\n"); for(i=0; i<=dc_gcd; i++) writeln_dcmplx(c_gcd[i]); printf("\n"); printf("the gcd got from common roots is:\n"); for(i=0; i<=dgcd; i++) writeln_dcmplx(gcd_coeff[2][i]); printf("\n"); if(l!= dc_gcd) { printf("Bug!!\n"); printf("a is:\n"); for(i=0; i<=n+l; i++) writeln_dcmplx(a[i]); printf("b is:\n"); for(i=0; i<=m+l; i++) writeln_dcmplx(b[i]); printf("a's roots are:\n"); for(i=0; i<n+l; i++) writeln_dcmplx(ra[i]); printf("b's roots are:\n"); for(i=0; i<m+l; i++) writeln_dcmplx(rb[i]); exit(1); } if(l!=dgcd) { printf("Bug!! (get_poly)\n"); exit(1); } for(i=0; i<=l; i++) { bug=1; for(j=0; j<=l; j++) { if(equal_dcmplx(c[i], c_gcd[j], tol)) bug=0; } if( bug==1 ) { printf(" Bug!!\n"); exit(1); } } for(i=0; i<=l; i++) { bug=1; for(j=0; j<=l; j++) { if(equal_dcmplx(c[i], gcd_coeff[2][j], tol)) bug=0; } if( bug==1 ) { printf(" Bug!!(get_poly)\n"); exit(1); } } printf(" the extended gcd result is correct !\n"); free(t1); free(t2); free(c_gcd); free(gcd_coeff[0]); free(gcd_coeff[1]); free(gcd_coeff[2]); free(gcd_coeff); }
graph_type::graph_type(point_arr const& special_points): _special_points(special_points) { add_poly(special_points); }
/* * Generate the triangles. * Returns the lists (edges & polys) via pointers to their heads. */ static void gen_triangle( int num_isolines, /* number of iso-lines input */ struct iso_curve *iso_lines, /* iso-lines input */ poly_struct **p_polys, /* list of polygons output */ edge_struct **p_edges) /* list of edges output */ { int i, j, grid_x_max = iso_lines->p_count; edge_struct *p_edge1, *p_edge2, *edge0, *edge1, *edge2, *pe_tail, *pe_tail2, *pe_temp; poly_struct *pp_tail; struct coordinate *p_vrtx1, * p_vrtx2; (*p_polys) = pp_tail = NULL; /* clear lists */ (*p_edges) = pe_tail = NULL; p_vrtx1 = iso_lines->points; /* first row of vertices */ p_edge1 = pe_tail = NULL; /* clear list of edges */ /* Generate edges of first row */ for (j = 0; j < grid_x_max - 1; j++) add_edge(p_vrtx1 + j, p_vrtx1 + j + 1, &p_edge1, &pe_tail); (*p_edges) = p_edge1; /* update main list */ /* * Combines vertices to edges and edges to triangles: * ================================================== * The edges are stored in the edge list, referenced by p_edges * (pe_tail points on last edge). * * Temporary pointers: * 1. p_edge2: Top horizontal edge list: +-----------------------+ 2 * 2. p_tail : end of middle edge list: |\ |\ |\ |\ |\ |\ | * | \| \| \| \| \| \| * 3. p_edge1: Bottom horizontal edge list: +-----------------------+ 1 * * pe_tail2 : end of list beginning at p_edge2 * pe_temp : position inside list beginning at p_edge1 * p_edges : head of the master edge list (part of our output) * p_vrtx1 : start of lower row of input vertices * p_vrtx2 : start of higher row of input vertices * * The routine generates two triangle Lower Upper 1 * upper one and lower one: | \ ---- * (Nums. are edges order in polys) 0| \1 0\ |2 * The polygons are stored in the polygon ---- \ | * list (*p_polys) (pp_tail points on 2 * last polygon). * 1 * ----------- * In addition, the edge lists are updated - | \ 0 | * each edge has two pointers on the two | \ | * (one active if boundary) polygons which 0|1 0\1 0|1 * uses it. These two pointer to polygons | \ | * are named: poly[0], poly[1]. The diagram | 1 \ | * on the right show how they are used for the ----------- * upper and lower polygons (INNER_MESH polygons only). 0 */ for (i = 1; i < num_isolines; i++) { /* Read next column and gen. polys. */ iso_lines = iso_lines->next; p_vrtx2 = iso_lines->points; /* next row of vertices */ p_edge2 = pe_tail2 = NULL; /* clear top horizontal list */ pe_temp = p_edge1; /* pointer in bottom list */ /* * Generate edges and triagles for next row: */ /* generate first vertical edge */ edge2 = add_edge(p_vrtx1, p_vrtx2, p_edges, &pe_tail); for (j = 0; j < grid_x_max - 1; j++) { /* copy vertical edge for lower triangle */ edge0 = edge2; if (pe_temp && pe_temp->vertex[0] == p_vrtx1 + j) { /* test lower edge */ edge2 = pe_temp; pe_temp = pe_temp->next; } else { edge2 = NULL; /* edge is undefined */ } /* generate diagonal edge */ edge1 = add_edge(p_vrtx1 + j + 1, p_vrtx2 + j, p_edges, &pe_tail); if (edge1) edge1->position = DIAGONAL; /* generate lower triangle */ add_poly(edge0, edge1, edge2, p_polys, &pp_tail); /* copy diagonal edge for upper triangle */ edge0 = edge1; /* generate upper edge */ edge1 = add_edge(p_vrtx2 + j, p_vrtx2 + j + 1, &p_edge2, &pe_tail2); /* generate vertical edge */ edge2 = add_edge(p_vrtx1 + j + 1, p_vrtx2 + j + 1, p_edges, &pe_tail); /* generate upper triangle */ add_poly(edge0, edge1, edge2, p_polys, &pp_tail); } if (p_edge2) { /* HBB 19991130 bugfix: if p_edge2 list is empty, * don't change p_edges list! Crashes by access * to NULL pointer pe_tail, the second time through, * otherwise */ if ((*p_edges)) { /* Chain new edges to main list. */ pe_tail->next = p_edge2; pe_tail = pe_tail2; } else { (*p_edges) = p_edge2; pe_tail = pe_tail2; } } /* this row finished, move list heads up one row: */ p_edge1 = p_edge2; p_vrtx1 = p_vrtx2; } /* Update the boundary flag, saved in each edge, and update indexes: */ pe_temp = (*p_edges); while (pe_temp) { if ((!(pe_temp->poly[0])) || (!(pe_temp->poly[1]))) (pe_temp->position) = BOUNDARY; pe_temp = pe_temp->next; } }
int main() { int choice, res, no1, no2, ch; double n, m, s1, s2, res1, ans, val, num; float x, y; double result = 0, n1 = 0, fradecimal; long y1; char c; char frabinary[100], hexa[MAX]; long int binaryval; div_t1 temp; poly * poly1, * poly2, * poly3; FILE *fp; printf("\n\n....NEW USER FIRST READ THE MANUAL TEXT FILE TO UNDERSTANS THE FUNCTIONS USAGE....\n\n"); while(1) { printmenu1(); printf("Enter your choice\n"); scanf("%d", &ch); switch(ch) { case 1: fp = fopen("Manual.txt", "r"); if(!fp) printf("Cannot open file\n"); while((c = fgetc(fp) )!= EOF) printf("%c", c); fclose(fp); break; case 2: while(1) { printmenu(); printf("Enter your choice\n"); scanf("%d" ,&choice); switch(choice) { case 1: printf(".....sqrt() function finds the square root of a number.....\n"); printf("Enter your number:\n"); scanf("%lf", &n); m = sqrt(n); //square root if( m == 0) { printf(" You entered negative number\n"); break; } printf("square root is %.3lf\n", m); waita(); break; case 2: printf(".....mod() finds remainder when one number is divided by 2nd number.....\n"); printf("enter the number to be divided :\t\n"); scanf("%lf",&s1); printf("enter the divisor:\t\n"); scanf("%lf",&s2); ans = fmod(s1, s2); //remainder printf("remainder is : %lf\n", ans); waita(); break; case 3: printf(".....fabs() finds the absolute value of floating point number.....\n"); printf("Enter the number to find the absolute value\n"); scanf("%lf", &val); res1 = fabs(val); //absolute value printf("The absolute value of %lf is %lf\n", val, res1); waita(); break; case 4: printf(".....ceilx() function finds ceil value of a number.....\n"); printf("Enter the value\n"); scanf("%lf", &val); ans = ceilx(val); //ceil function printf("Value=%lf\n", ans); waita(); break; case 5: printf(".....floorx() function finds floor value of a number.....\n"); printf("Enter the value\n"); scanf("%lf", &val); ans = floorx(val); //floor function printf("Value=%lf\n", ans); waita(); break; case 6: printf(".....expoential() function finds expoential value of a number i.e. e^x.....\n"); printf("Enter the value of x\n"); scanf("%lf", &n); printf("e^x = %lf\n", exponential(n)); //exponential function waita(); break; case 7: printf(".....hypot()finds the value of hypotenuse when two sides are given.....\n"); printf("Enter sides: \n"); scanf ("%lf %lf",&s1,&s2); printf("Hypotenus of %f %f is: %f\n", s1, s2,hypot(s1,s2)); //hypotenuse function waita(); break; case 8: printf(".....cbrt() finds the cube root of proper number i.e. cbrt(8)= 2.....\n"); printf("enter the number to find the cube root\n"); scanf("%lf",&n1); if(n1 < 0) { printf("enter only +ve integer value\n"); waita(); break; } result = cbrtx(n1); //cube root function if(result) printf("cube root of %lf is %lf\n",n1,result); else { printf("not a proper value for finding the cube root\n"); waita(); break; } waita(); break; case 9: printf(".....pow() function finds the x^y power.....\n"); printf("Enter the number and the power\n"); scanf("%lf%lf", &s1, &s2); res1 = Pow(s1, s2); //power function printf("The %lf^%lf is %lf\n", s1, s2, res1); waita(); break; case 10: printf(".....trunc() function truncates the floating points.....\n"); printf("Enter the value for truncating\n"); scanf("%lf", &s1); res1 = trunc(s1); // truncating a number printf("The value after truncating is %lf\n", res1); waita(); break; case 11: printf(".....round() function rounds up a floating point number..... \n"); printf("Enter the value for rounding\n"); scanf("%lf", &s1); res1 = round(s1); //rounding a number printf("The value after rounding is %lf\n", res1); waita(); break; case 12: printf(".....abs() function finds absolute value of integer number.....\n"); printf("Enter the integer number to find the absolute value\n"); scanf("%lf", &n); if(n - (int)n == 0) { res = abs(n); //absolute value printf("The absolute value of %lf is %d\n", n, res); waita(); break; } else { printf("Enter integer number\n"); waita(); break; } waita(); break; case 13: printf(".....fmax() function finds maximum between two numbers.....\n"); printf("Enter two numbers to find maximun number\n"); scanf("%lf%lf", &s1, &s2); res1 = fmax(s1,s2); printf("The max number is %f\n",res1); waita(); break; case 14: printf(".....fmin() function finds minimum between two numbers.....\n"); printf("Enter two numbers to find minimum number\n"); scanf("%lf%lf", &s1, &s2); res1 = fmin(s1,s2); printf("The min number is %f\n",res1); waita(); break; case 15: printf(".....fdim()finds +ve difference bet^n 2 no's & if fails it returns 0.....\n"); printf("Enter two numbers to find difference of two numbers\n"); scanf("%lf%lf", &s1, &s2); res1 = fdim(s1,s2); if(res1 == 0) { printf("This functions returns 0 when first number is less than or equal to second number\n"); waita(); break; } printf("The positive Difference is %f\n",res1); waita(); break; case 16: printf(".....roundf() function rounds up a floating value..... \n"); printf("Enter the value for rounding\n"); scanf("%f", &x); y = roundf(x); printf("The value after rounding is %f\n", y); waita(); break; case 17: printf(".....lround() function rounds up a long value.....\n"); printf("Enter the value for rounding\n"); scanf("%lf", &n); y1 = lround(n); printf("The value after rounding is %li\n", y1); waita(); break; case 18: printf(".....add_poly() function adds two polynomials.....\n"); printf("\nCreate 1st expression\n"); create(&poly1); printf("\nStored the 1st expression"); show(poly1); printf("\nCreate 2nd expression\n"); create(&poly2); printf("\nStored the 2nd expression"); show(poly2); add_poly(&poly3, poly1, poly2); show(poly3); waita(); break; case 19: printf(".....sub_poly() function subtract two polynomials..... \n"); printf("\nCreate 1st expression\n"); create(&poly1); printf("\nStored the 1st expression"); show(poly1); printf("\nCreate 2nd expression\n"); create(&poly2); printf("\nStored the 2nd expression"); show(poly2); sub_poly(&poly3, poly1, poly2); show(poly3); waita(); break; case 20: printf(".....division() function givesquotient and remainder after division.....\n"); printf("Enter divident\n"); scanf("%d", &no1); printf("Enter divisor\n"); scanf("%d", &no2); temp = division(no1, no2); printf("quotient=%d\tremainder=%d\n", temp.quot, temp.rem); waita(); break; case 21: printf(".....ldexp() function returns value * 2^expoential..... \n"); printf("Enter the value\n"); scanf("%lf", &n); printf("Enter the integer exponent\n"); scanf("%d", &no1); m = ldexp(n, no1); printf("value=%lf\n", m); waita(); break;; case 22: printf(".....exp2() function returns 2^expoential.....\n"); printf("Enter the expoential\n"); scanf("%lf", &n); m = exp2(n); printf("exp2(%lf)=%lf\n", n, m); waita(); break; case 23: printf(".....tgamma() fuction calculates gamma value.....\n"); printf("Enter the number to find gamma value\n"); scanf("%lf", &num); if( num <= 0) { printf("Gamma of negative number and 0 is not defined \n"); waita(); break; } ans = tgamma(num); printf("gamma(%lf)=%lf\n", num, ans); waita(); break; case 24: printf(".....fact() function returns factorial of a number..... \n"); printf("Enter number to find factorial\n"); scanf("%lf", &n); ans = fact(n); printf("The factorial of %lf is %lf\n", n, ans); waita(); break; case 25: printf(".....square() function calculates square of a number.....\n"); printf("Enter number to find square of entered number\n"); scanf("%lf", &n); ans = square(n); printf("The square of %lf is %lf\n",n, ans); waita(); break; case 26: printf(".....cube() function calculates cube of a number..... \n"); printf("Enter number to find cube of a entered number\n"); scanf("%lf", &n); ans = cube(n); printf("The cube of %lf is %lf\n",n, ans); waita(); break; case 27: printf("dec_bin() function converts decimal number into binary \n"); printf("Enter any fractional Decimal number\n"); scanf("%lf", &fradecimal); printf("eduivalent binary value is %lf\n",dec_bin(fradecimal)); waita(); break; case 28: printf("bin_dec() function converts binary number into decimal \n"); printf("Enter any fractional Binary number\n"); scanf("%s", frabinary); printf("eduivalent decimal value is %lf\n",bin_dec(frabinary)); waita(); break; case 29: printf("This fun. converts decimal number to octal number\n"); printf("Enter a decimal number:\n "); scanf("%d", &no1); printf("%d in decimal = %d in octal\n", no1, decimal_octal(no1)); waita(); break; case 30: printf("This fun. converts octal number to decimal number\n"); printf("Enter a octal number:\n "); scanf("%d", &no1); printf("%d in octal = %d in decimal\n", no1, decimal_octal(no1)); waita(); break; case 31: printf("This fun. converts binary number to octal number\n"); printf("Enter a binary number:\n "); scanf("%d",&no1); printf("%d in binary = %d in octal\n", no1, binary_octal(no1)); waita(); break; case 32: printf("This fun. converts octal number to binary number\n"); printf("Enter a octal number:\n "); scanf("%d",&no1); printf("%d in octal = %d in binary\n",no1, octal_binary(no1)); waita(); break; case 33: printf("This function converts binary into hex number\n"); printf("Enter the binary number:\n "); scanf("%ld", &binaryval); printf("Equivalent hexadecimal value: %lX\n", binary_hex(binaryval)); waita(); break; case 34: printf("This function converts hex into binary number\n"); printf("Enter the value for hexadecimal\n "); scanf("%s", hexa); hex_binary(hexa); waita(); break; case 35: return 0; default: printf(".....wrong choice.....\n"); } } case 3: return 0; default: printf("Invalid Choice\n"); } } return 0; }