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
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).
C – EXPRESSION STATEMENT EXAMPLE PROGRAM :
int add(int p, int q);
printf(“Enter two numbers \n”);
printf(“\nSum of %d and %d is %d”, a,b,c);
int add(int p, int q)
result = p+q
|Enter two numbers
Sum of 10 and 20 is 30