answersLogoWhite

0


Best Answer

If I'm reading your question right,loops and if statements with one line of code after can be terminated with a semicolon

ie,

if(a > b)

b = a;

is fine. HOWEVER, it is better coding practice to use braces to contain your code. Looks tidier and more uniform.

eg,

if(a > b){

b = a;

}

If you are talking about breaking out of a loop, try using 'break'.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can an if statement or if loop be terminated with a semicolon in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Where you have to put semicolon in c programming?

For clasesses it defines from which class to inherit. :: means area of visibility in certain name space.


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.


Can an for loop be terminated with a semicolon in c language?

Sure.for (i=0; i


What is the use of semicolon for loop in some cases in c?

In some cases it is a separator:for (exp1; exp2; exp3) statement


Why you use colon in C language?

In C (and C++ and Java), the semicolon is used to mark the end of a statement. It is also used the separate the expressions in a for loop.


What are break and continue statement in c language?

Break is used to exit the closest loop. Continue will cause the program to go to the beginning of the loop. for(int x=0;x<10;x++) { //continue; for(int y=0;y<10;y++) { break; } } The break statement causes the inner loop to stop at the first iteration. If the continue statement was uncommented, the inner loop would never be executed because the program would jump back to the beginning(until x = 10 of course).


What statement marks the end of a do while loop?

It's the semicolon after the while ()part:i= 0;do printf ("%d %s\n", i, argv[i]); while (++i


Every complete statement ends with a?

Any teacher will expect you to answer by saying a semicolon (;), but this is not strictly true. First of all, the definition of a "line of code" varies from teacher to teacher and textbook to textbook. Second, even the Java Language Specification lists several types of Java statements which do not need to end in a semicolon.In general, a complete Java statement will end in either of semicolon or a closing block brace.


What is the difference between the usage of semicolon and comma BASIC progamming?

A semicolon can be used for separating the initial value, condition, and increment statement within a for loop. A comma can be used to separate elements of an array and parameters for methods and classes.


For loop in c language?

for(assigning initial value;condition;increment/decrement) { statement; }


What is iterations in c language?

An iteration is an instance of a structured loop statement (for, while or do-while).


In endless loop the value of i2 k10 and the loop will terminated when value of you is greater than k and the value of k is assign to 17 after the loop and it is said to endless loop why?

"In endless loop the value of i2 k10 and the loop will terminated when value of you is greater than k and the value of k is assign to 17 after the loop and it is said to endless loop why?"