printf("Hello, world!\n"); printf("%d\n", i); sqrt(144.); getchar();
printf("sum = %d\n", a + b + c);
c = sqrt(a * a + b * b); x = r * cos(theta); i = f1(f2(j));
void printMessage(void) { printf("Programming is fun.\n"); }
int multbytwo(int x) { return x * 2; }
void multbytwo(int *x) { *x = *x * 2; } void main(void) { int a = 4; multbytwo(&a); mutlbytwo(&a); printf("a is %d\n", a); }
struct date { int month; // one member int day; int year; }; // this is a new type struct date today; // this is a variable of the new type
today.day = 2; today.year = 2005; today.month = 2;
struct tm { int tm_sec; /* seconds after the minute - [0, 61] */ /* for leap seconds */ int tm_min; /* minutes after the hour - [0, 59] */ int tm_hour; /* hour since midnight - [0, 23] */ int tm_mday; /* day of the month - [1, 31] */ int tm_mon; /* months since January - [0, 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday - [0, 6] */ int tm_yday; /* days since January 1 - [0, 365] */ int tm_isdst; /* flag for daylight savings time */ };
void printndots(int n) { if (n<1) return; printf("."); printndots(n-1); }