C – Expression Statements

Home/C - Tutorial/C - Statements/C – Expression Statements
C – Expression Statements 2017-06-12T09:35:57+00:00

Expression statements

Most of the statements in a C program are expression statements. An expression statement consists of an expression followed by a semicolon. The execution of an expression causes the expression to be evaluated. The lines
A+=20;           and
printf(“Hello, Good morning!\n”);
are all expression statements.

Several Expression statements are shown below.

display(a,b);                   /* A function call*/
c=a+b;                             /* An assignment statement*/
c+sum(a+b);                  /* A valid , but strange statement*/
;                                /*An empty or null statement*/

The first statement executes a function call. The second is an assignment statement. The third expression, though strange, is still evaluated by the compiler because the function add(a,b) may perform some necessary task. The final expression shows that a statement can be empty (sometimes called a null statement).

Example :

Output :

Enter two numbers



Sum of 10 and 20 is 30

Prev Next