answersLogoWhite

0


Best Answer

syntax: for(initialization;condition;increment) { statements s1; statements s2; } #include<stdio.h> main() { int i,n=5; for(i=0;i<n;i=i+1) { printf("the number s are %d", i); } }

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the syntax of for loop statement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;


Is an infinite loop an example of a syntax error?

No. A syntax error is a statement that fails to compile. Infinite loops are simply loops for which the number of iterations is unknown. However, all loops, whether counted loops or infinite loops, must have a reachable exit condition. If a loop does not have a reachable exit condition then it is a logic error, not a syntax error.


Any violation in the syntax of a program statement is called logic error?

No. A violation in the syntax of a program statement is called a syntax error.


Why for loop is not terminated in c?

Of course the for loop is terminated in C. All statements are terminated. Look at the syntax of the for statement... for (init-statement; test-condition; loop-statement) body-statement; That looks quite terminated to me. (By the semi-colon) Perhaps you are thinking about statement blocks... for (init-statement; test-condition; loop-statement) { statement; statement; ... statement; } ... Well, that is just fine because the body-statement, like any other statement, can be replaced by one or more statements enclosed in braces. There is still a terminating semi-colon on each statement. if i am understanding ur ques. right then according to me it is correct that for loop is not terminated because we do not execute for loop.we only check the conditions. those statements are terminated which we want to execute. because using a semicolon or terminating the statement means that statement is execitable.


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.

Related questions

What the syntax of for loop in c?

for (&lt;exp1&gt;; &lt;exp2&gt;; &lt;exp3&gt;) &lt;statement&gt; exp1 and exp3 are optional; statement can be null-statement or block-statement. Correction: All expressions are optional. An infinite loop has no expressions: for(;;);


Difference between break and continue statements in wml?

Break statements:-its terminates the current while or for loop and continue the program execution from the statement following the terminated.NOTE:-note that it is wmlscript syntax error to use the break statement outside of while or a for statements.example;Breakstatement:Break;Continue statement:-this statement terminate execution of a block of statementin while or for loop and continues execution of loop with the next iteration.note that the continue statement does not terminate the execution of loop and also is wmlscript syntax error to use the break statement outside of while or a for statements.-> in while loop, it jumps back to the condition.-> in for loop,it jumpsto the update expression.syntax:continuestatement:continue;


Are The two parts of a while statement are known as the loop head and the loop body?

The syntax of while is: while (expression)statementThe 'while (expression)' part would be then 'head'; the 'statement' would be the 'body'


Is it possible to use a for loop in place of a while loop?

Yes. while loop consist of only condition statement to make for loop look as while loop we can use syntax shown below: for(;condition;) eg: for(;i&lt;=n;)


How do you use if statement syntax in a for loop?

You can use any number of if staments within a for-loop, eg: for (i=0; i&lt;10; ++i) { if (i=1) printf ("%d=1\n",i); }


Is an infinite loop an example of a syntax error?

No. A syntax error is a statement that fails to compile. Infinite loops are simply loops for which the number of iterations is unknown. However, all loops, whether counted loops or infinite loops, must have a reachable exit condition. If a loop does not have a reachable exit condition then it is a logic error, not a syntax error.


What is the definition and syntax of for next loops?

loop within in a loop is called for next loop


Any violation in the syntax of a program statement is called logic error?

No. A violation in the syntax of a program statement is called a syntax error.


Why for loop is not terminated in c?

Of course the for loop is terminated in C. All statements are terminated. Look at the syntax of the for statement... for (init-statement; test-condition; loop-statement) body-statement; That looks quite terminated to me. (By the semi-colon) Perhaps you are thinking about statement blocks... for (init-statement; test-condition; loop-statement) { statement; statement; ... statement; } ... Well, that is just fine because the body-statement, like any other statement, can be replaced by one or more statements enclosed in braces. There is still a terminating semi-colon on each statement. if i am understanding ur ques. right then according to me it is correct that for loop is not terminated because we do not execute for loop.we only check the conditions. those statements are terminated which we want to execute. because using a semicolon or terminating the statement means that statement is execitable.


Syntax of for loop in c language?

for(i=0;i&lt;=0;i++)


What is syntax of a remark statement?

The only language, which has remark-statement, is BASIC. Syntax: REM any text


What is while . do statement?

Do while is a conditional statement which is used to check the certain condition and then perform the operation. usally the do word written first and the the loop occurs and then the while conditionoccurs. The main thing in case of do while is that it will perform the operation written in the loop at least once because it executes first and then check the condition. The syntax for the do -while loop can be as follows..... do { ............... ............... }while(-)