answersLogoWhite

0


Best Answer

well , in a rather simple way

an expression is a combination of of literals , variables , operators , functions calls which produces a particular value to be used in any other context

while a statement is an instruction to the computer telling it what to do for instance assigning an expression value to a variable , cause it produces an instructions tells the computer to assign a value to something.

to be more accurate , you can tell if A is a statement or an expression accurately by looking at the context which is been used in

well , in a rather simple way

an expression is a combination of of literals , variables , operators , functions calls which produces a particular value to be used in any other context

while a statement is an instruction to the computer telling it what to do for instance assigning an expression value to a variable , cause it produces an instructions tells the computer to assign a value to something.

to be more accurate , you can tell if A is a statement or an expression accurately by looking at the context which is been used in

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

It depends on the language in context/question.

The answer to this question is actually in that computer language specification. Every computer language has its own specification/definition of "expression" and "statement". There maybe some languages that do not even define what a statement is (no notion of statements, only expressions)

If you have 1 particular computer language in mind, it may break the concept below

In general:

  • An EXPRESSION can be evaluated to a value.
  • A statement does something.
  • Same terms may not be in the same definition in 2 different languages

The evaluation of an expression may do something itself, like calling a function in an expression like:

100 * Call_A_SUB()

Call_A_SUB() is a function returns a value to be multiplied to 100. It may have done something (statements) before returning a final value!!

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

An expression can be a statement, but some statements aren't expressions. Examples for the former: x++, y = 3, printf ("Hello"); examples for the latter: if, else, while, for, do, switch, break, continue, return

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Expressions can only be used as statements if you're using an assignment ("=") operator. Every statement must commit an action of some sort, whether it's modifying a variable or calling a function; so comparison expressions by themselves will do nothing. For instance, the following code is futile:

myvar==5;

You would need to use this within an 'if' statement at the very least:

if (myvar==5) { dosomething(); }

Or within a function:

doanotherthing(myvar==5);

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is diffrence between statement and expression in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

The arguments in an IF function are?

IF, in C and C++, is not a function - it is a statement. There are two parameters... if (expression) statement; The expression is evaluated. If it has logical result true, or arithmentic result not zero, the statement is executed; if not, the statement is not executed. The statement can be a single statement, in which it is terminated with a semi-colon, or it can be a block of statements, in which it is surrounded by braces.


Definition and comments for loop?

The C and C++ for loop is defined as...for (init-expression; test-expression; loop-expression) loop-statement;The init-expression is executed once.At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.


What is the method used to implement an if else statement in C?

The else statement is an optional part of an if statement that is executed if the primary if condition is false.if (condition) true_statementelse false_statement


What is the character used at the end of executable statements in C plus plus?

The semi-colon converts a C++ expression into a statement.


What is looping in c plus plus?

A loop in computer languages is a set of statements that execute repeatedly, based on some criteria.In C and C++, the three looping statements are while, do, and for...while (test-expression) statement;/* statement executes zero or more times, until test-expression is false, test first */do statement while (test-expression);/* statement executes one or more times, until test-expression is false, test last */for (init-expression, test-expression, loop-expression) statement;/* init-expression executed once, at beginning *//* statement executes zero or more times, until test-expression is false, test first *//* loop-expression evaluated at end of each iteration */Often, statement, is a set of statements, such as...while (test-expression) {... statements}

Related questions

What do you mean by statements in C?

A statement in C is an expression terminated with a semi-colon. That is, a semi-colon turns an expression into a statement.


What do you mean by statements in C program?

A statement in C is an expression terminated with a semi-colon. That is, a semi-colon turns an expression into a statement.


What is for statement in c?

It is one of the statements. Its syntax in BNF is the following: statement ::= for_statement for_statement ::= 'for' '(' opt_expression ';' expression ';' expression ')' statement


The arguments in an IF function are?

IF, in C and C++, is not a function - it is a statement. There are two parameters... if (expression) statement; The expression is evaluated. If it has logical result true, or arithmentic result not zero, the statement is executed; if not, the statement is not executed. The statement can be a single statement, in which it is terminated with a semi-colon, or it can be a block of statements, in which it is surrounded by braces.


How many arithmetic statement in c?

Only one: expression. Yes, in C expression is one of the statements. Some other statements are: if, do, goto, while, for, switch, break, continue, return, NULL-statement, compound-statement.


Definition and comments for loop?

The C and C++ for loop is defined as...for (init-expression; test-expression; loop-expression) loop-statement;The init-expression is executed once.At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.


Which operator will let us use multiple statement in an expression in c?

The comma operator will let you use multiple statements in an expression in C or C++.Strictly speaking, you cannot have a statement inside an expression, for example the following is completely wrong:int n;n = 1 + for (i=0; i


How do you use for loop in c?

The for loop in C, and C++ and Java, is defined as ...for (init-expression, limit-expression, loop-expression) statement;The init-expression is evaluated once. Then the limit-expression is evaluated. If it is true, the statement is evaluated, which can be a block of statements, or even a null statement, otherwise, control transfers out of the loop. If the statement is executed, then the loop-expression is evaluated, and control transfers back to the limit-expression.As an example, to print the numbers 1 through 10 ...for (int i = 1; i


What is meant by block statement in c language?

BNF:statements -> | statement statementsstatement -> block | null_statement | expression_statement | if_statement | while_statement | ...null_statement -> ;expression_statement -> expression ;block -> { declarations statements }declarations -> | declaration declarationsif_statement -> if ( expression )statement


What is if statement in c language?

first i would like to tell about if . if is keyword in c language . if is check the condition(expression) .if the expression is non zero value the condition is true .it will the go through the fallowing operations .other wise the condition is failed. if(expression) { } if the expression is >0 ,<0 these statements are execute inside the if statement. if the expression is =0 condition is failed.


What is the method used to implement an if else statement in C?

The else statement is an optional part of an if statement that is executed if the primary if condition is false.if (condition) true_statementelse false_statement


What is the format of if statement in c plus plus?

Syntax:if (expression)statement;[elsestatement;]The expression must evaluate to a boolean value, where zero is false and all non-zero values are true. The statement (including the optional else statement) may be simple or compound, and may include a nested if statement. When the expression evaluates true, the first statement is invoked. If an else statement is provided, it is only executed when the expression evaluates false. After the appropriate statement is invoked, execution passes to the statement that immediately follows the entire if statement.