Home > Back-end >  How make to make calculation accuracy improved
How make to make calculation accuracy improved

Time:03-05

# include & lt; Stdio. H> # include # include & lt; Math. H> # include & lt; Stdlib. H> To void the start ();/* * define each function/void main () {void a (); Void (b); Void (c); Void (d); Void (e); int n; While (n!=6)//interface {printf (" please select you want to calculate methods: \ n "); Printf (" addition please click _1 \ n "); Printf (" subtraction please click _2 \ n "); Printf (" multiplication please click _3 \ n "); Printf (" please click _4 division \ n "); Printf (" hexadecimal conversion _5 \ n "); Printf (" exit _6 \ n "); Printf (" input option code: "); {//input the wrong option printf (" please input the correct number, \ n \ n "); } the scanf (" % d ", & amp; n); The switch (n) {case 1: a (); break; Case 2: (b); break; Case 3: (c); break; Case 4: d (); break; Case 5: (e); break; Case 6: printf (" \ n * * * * * * * * * * * * * * * * * * * thank you! * * * * * * * * * * * * * * * * * * * \ n "); break; break; }} getchar (); }/* */sub function void a () {//addition double x, y, the Result; Printf (" please enter the augend: "); Lf the scanf (" % ", & amp; X); Printf (" please enter a number: "); Lf the scanf (" % ", & amp; Y); Result=x + y; Printf (" the Result is: % lf \ n \ n ", Result); {//calculated results printf (" to get a result, \ n \ n "); } system (" pause ");//press any key to continue the system (" CLS ");//screen clearing}/* */sub function void b () {//subtraction double x, y, the Result; Printf (" please enter the minuend: "); Lf the scanf (" % ", & amp; X); Printf (" please input reduction: "); Lf the scanf (" % ", & amp; Y); Result=x - y; Printf (" the Result is: % lf \ n \ n ", Result); {//calculated results printf (" to get a result, \ n \ n "); } system (" pause ");//press any key to continue the system (" CLS ");//screen clearing}/* */sub function void c () {//multiplication double x, y, the Result; Printf (" please enter the multiplicand: "); Lf the scanf (" % ", & amp; X); Printf (" please enter a multiplier: "); Lf the scanf (" % ", & amp; Y); Result=x * y; Printf (" the Result is: % lf \ n \ n ", Result); {//calculated results printf (" to get a result, \ n \ n "); } system (" pause ");//press any key to continue the system (" CLS ");//screen clearing}/* */sub function void d () {//division double x, y, the Result; Printf (" please enter the dividend: "); Lf the scanf (" % ", & amp; X); Printf (" please input divisor: "); Lf the scanf (" % ", & amp; Y); Result=x/y; Printf (" the Result is: % lf \ n \ n ", Result); {//calculated results printf (" to get a result, \ n \ n "); } system (" pause ");//press any key to continue the system (" CLS ");//screen clearing}/* */sub function void e () {//hexadecimal conversion code int Ary_10;//define a binary variable char string [32].//binary variables defined printf (" please enter the need to convert decimal number: "); The scanf (" % d ", & amp; Ary_10); Itoa (Ary_10, string, 2); Binary: printf (" % s \ n ", & amp; String); Printf (" octal: % o \ n ", & amp; Ary_10); Printf (" hexadecimal: % x \ n ", & amp; Ary_10); {//calculated results printf (" to get a result, \ n \ n "); } system (" pause ");//press any key to continue the system (" CLS "); }//clear screen
  • Related