/* Run C program on Sun workstation/UNIX environment */ :: 1 ccsun8 :c % script examp.prt 2 Script started on Mon Jan 3 22:44:11 1994 3 ccsun8 :c % cat > try.c 4 int main() 5 { printf(" Hello there!\n"); 6 printf(" sin(1.57)=%f\n", sin(1.57)); 7 printf(" cos(1.57)=%7.4f see?\n",cos(1.57)); 8 printf(" 100,200,300= %d and %5d and %2d\n",100,200,300); 9 return 0; 10 } 11 ccsun8 :c % cc try.c 12 ld: Undefined symbol 13 _cos 14 _sin 15 ccsun8 :c % cc -lm try.c 16 ld: Undefined symbol 17 _cos 18 _sin 19 ccsun8 :c % cc try.c -lm 20 ccsun8 :c % a.out 21 Hello there! 22 sin(1.57)=1.570001 23 cos(1.57)= 1.5700 see? 24 100,200,300= 100 and 200 and 300 25 ccsun8 :c % man cc 26 ccsun8 :c % vi try.c 27 (...editing ) 28 (...editing ) 29 ccsun8 :c % cat -n try.c 30 1 #include 31 2 int main() 32 3 { printf(" Hello there!\n"); 33 4 printf(" sin(1.57)=%f\n", sin(1.57)); 34 5 printf(" cos(1.57)=%7.4f see?\n",cos(1.57)); 35 6 printf(" 100,200,300= %d and %5d and %2d\n",100,200,300); 36 7 return 0; 37 8 } 38 ccsun8 :c % cc try.c -lm 39 ccsun8 :c % a.out 40 Hello there! 41 sin(1.57)=1.000000 42 cos(1.57)= 0.0008 see? 43 100,200,300= 100 and 200 and 300 44 ccsun8 :c % 45 ccsun8 :c % ls -l try* 46 -rw-r--r-- 1 tsaiwn 224 Jan 3 22:44 try.c 47 48 ccsun8 :c % exit 49 exit 50 script done on Mon Jan 3 22:51:26 1994 (Also, try "g++ try.c -lm" and/or "gcc try.c -lg++ -lm" ) (On PC/MS DOS, use tcc (or bcc) instead of "cc". Or use Borland C++ IDE( bc ), Turbo C++ IDE (tc) or MS Visual C++) 4.