Skip to content

Latest commit

 

History

History
58 lines (52 loc) · 1.78 KB

File metadata and controls

58 lines (52 loc) · 1.78 KB
title Expression Statement (C) | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-language
ms.tgt_pltfrm
ms.topic article
dev_langs
C++
helpviewer_keywords
statements, expression
expression statements
ms.assetid 1085982b-dc16-4c1e-9ddd-0cd85c8fe2e3
caps.latest.revision 8
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Expression Statement (C)

When an expression statement is executed, the expression is evaluated according to the rules outlined in Expressions and Assignments.

Syntax

expression-statement:
expression opt**;**

All side effects from the expression evaluation are completed before the next statement is executed. An empty expression statement is called a null statement. See The Null Statement for more information.

These examples demonstrate expression statements.

x = ( y + 3 );            /* x is assigned the value of y + 3  */  
x++;                      /* x is incremented                  */  
x = y = 0;                /* Both x and y are initialized to 0 */  
proc( arg1, arg2 );       /* Function call returning void      */  
y = z = ( f( x ) + 3 );   /* A function-call expression        */  

In the last statement, the function-call expression, the value of the expression, which includes any value returned by the function, is increased by 3 and then assigned to both the variables y and z.

See Also

Statements