/* fcf.tc - lrb - 1/13/9 */ /* converts between degrees F and degrees C */ fcf [ hilo '1';color '4';pl"";ps"fcf.tc - lrb - 1/13/9" pl"convert F to C or C to F";pl"";color '7' char fc,sn;int temp,temp1 while (!((fc=='F')+(fc=='C'))) [ pl"F -> C (type F) or C -> F (type C) " fc=gc;if (fc>='c') fc=fc-('a'-'A') ] if (fc=='F') [ pl"";pl"Enter F (e.g. 73, 0) : " temp=gn temp1=(5*temp-160)%9;temp=(5*temp-160)/9 if (temp1<0) [temp=-temp;temp1=-temp1;sn='-'] pl"C is ";if (sn) putchar sn pnp temp;putchar'.';dpf(temp1,9,2) ] else [ pl"";pl"Enter C (e.g. 22, 101) : " temp=gn temp1=(9*temp+160)%5;temp=(9*temp+160)/5 if (temp1<0) [temp=-temp;temp1=-temp1;sn='-'] pl"F is ";if (sn) putchar sn pnp temp;putchar'.';dpf(temp1,5,2) ] pl"";hilo '0' ] dpf int n,d,p [ /* display proper fraction n/d as decimal number */ /* with p digit precision */ int w w=10*n/d if (p) [ pnp w dpf(10*n%d,d,p-1) /* recursive call */ ] ] pnp int n [ /* pn sans leading space */ MC n,14 ]