answersLogoWhite

0

What is a statement in C plus plus?

Updated: 8/10/2023
User Avatar

Wiki User

10y ago

Best Answer

A statement may be simple or compound. The following examples are all simple statements:

int i=1;

i++;

std::cout<<i<<std::endl;

Note that a simple statement ends with a semi-colon.

A compound statement is a group of simple statements enclosed in braces. Compound statements usually begin with an opening statement, such as for, if, switch, etc.

for(int i=0; i<10; ++i)

{

int j=i*i;

std::cout<<j<<std::endl;

}

In this example, the compound statement begins with the for keyword and ends at the closing brace. Everything between the braces is treated as a single statement composed from simple statements. If there were only one simple statement, the braces would be optional, but the statement would still be regarded as a compound statement.

The comma operator can also be used to form compound statements (braces are neither required nor implied):

int i=1, j=2;

The compiler treats this as if it were written in full:

int i=1;

int j=2;

User Avatar

Wiki User

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

Wiki User

12y ago

An expression can be a statement in itself, but there are other statements which aren't expressions:

Examples for expression statements:

x= x+1;

printf ("Hello");

Examples for non-expression statements:

return 0;

break;

for (i=0; i<3; ++i);

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

Like many languages, C provides two methods to control the flow of execution: branching and looping.

Looping is typically achieved with for, while and do-while statements, all of which are structured loops.

Branching is typically achieved with if and switch statements as well as the ternary operator (?:).

In addition, the break, continue, goto and return statements are often used in conjunction with if and switch statements.

  • The break statement is used to exit the nearest enclosing scope of a switch or loop.
  • The continue statement can only be used inside a structured loop, immediately passing control to the nearest controlling for or while statement.
  • The goto statement forces a jump to a code label somewhere within the scope of the current function.
  • The return statement is used to exit a function and return a value to the caller unless the function's type is declared void.
This answer is:
User Avatar

User Avatar

Wiki User

11y ago

There is no such thing as 'statement of C Programming'. On the other hand, statement in C programming is a piece of code, eg:

puts ("Hello, world");

++argc;

{ puts ("compound statement"); }

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

statement is a sentence which carry a particular action.

(Eg)

printf("Hello");

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A statement is a line of code that executes a function, sets a variable, or does other tasks within the program.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

here is an example:

puts ("Hello world");

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

No such thing.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

america

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a statement in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which statement is not frequently used in C plus plus?

The goto statement.


What is the deffernce of the switch statement and the if statement in c plus plus?

If statement is single selection statement,whereas the switch statement is multiple selective.


Basic control structure available in c plus plus?

The basic control structure in C++ is the if statement.


A c plus plus statement that invokes a function is known as?

...a function call.


Which statement in C plus plus is used to implement a decision structure in its simplest form-that of choosing between two alternatives?

if (condition) statement else statement;


What is the function of visual c plus plus switch condition?

The switch / case 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.


How can write the name in c plus plus language without using cout statement?

I believe, you can use C-function - printf().


How can you print your name in c or c plus plus with out using semi column?

You can not print your name in C without a semi colon because according to the rules of C every statement should end with a semi colon.In fact without the semi colon it fails to be a valid C statement.


Can you write plus at end of c statement?

No. That would be a syntax error. Only a right semicolon (;) can go at the end of a statement.


What statement describes the function c equals 5g plus 8?

It is an equation in two variables, c and g.


What are the conditional statement of turbo c plus plus dos based?

Statements that check an expression then may or may not execute a statement or group of statements depending on the result of the condition.