
Appendix C
Introduction to C for R
Programmers
The C language is quite complex, and C++ is even more so. The goal of
this appendix is to give a start at a reading ability in the C language for
those familiar with R.
C.0.1 Sample Program
// Learn . c
// in p ut s 5 numbers from the keyboard ,
// sq u a re s and p r i n t s them
// i n c l u d e d e f i n i t i o n s needed for sta ndard I /O
#include <s t d i o . h>
// f u n c t i o n to square the e lements o f an a r r a y x ,
// o f l e n g t h n , in−p l a c e ; both arguments a r e o f
// i n t e g e r
int sq r ( int ∗x , int n ) {
// a l l o c a t e space for an i n t e g e r i
int i ;
// for loop , i = ...