P. 1
C and C++ in 5 days

C and C++ in 5 days

|Views: 184|Likes:
Published by xinuxnet
learn C and C++ in five days
learn C and C++ in five days

More info:

Published by: xinuxnet on Jan 19, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





In C, there is no distinction between functions and procedures. There is a distinction
between statements and expressions, but it is usually possible to use an expression as a
statement. For example, the following is legal C code (note use of /* …*/ for

void main(int argc, char *argv[])

int i;

/* this is an expression */


This is a silly example, but there are cases where the result of an expression is not
needed, just its side effect (i.e., what it changes in the global environment).
Functions that do not return a result are declared to return type void, which is a
general non-type also used to specify pointers that can’t be dereferenced, among other

A few examples of expressions that might be considered statements in other


•assignment—done with “=” in C—so for example, it’s possible to do a string of
initializations in one go (comparison for equality uses “==”):
int i,j;
i = j = 0;

/* j = 0 is an expression: returns new value of j */

•procedure call—always a function call in C, even if no value is returned (on the other
hand a value-returning function can be called as if it were a procedure call, in which
case the value is thrown away)

•increment (var_name++) and decrement (var_name--): the exact behaviour of these
constructs is too complex for an introduction; they are explained more fully later

Unlike some languages (e.g., LISP, Algol-68) that treat everything as expressions,
most other statements in C cannot be used to return a value. These include selection (if
and switch), loops (while, for and do…while—the latter like a Pascal repeat) and {}


You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->