Question:
What is the use of semicolon at the end of every statement?
Answer:
If semicolon comes in a statement means its ending point of the statement ... Source: CoolInterview.com
Answered by: Raghunathk | Date: 8/14/2008
| Contact Raghunathk
As we know that C is a free form language, semicolon is the only symbol that tells compiler about the end of a statement. No other symbol can be used for marking the end of a statement. Source: CoolInterview.com
Answered by: Pranjal Gururani | Date: 8/18/2008
| Contact Pranjal Gururani
semicolon terminates the statement. when semicolon comes after any part it doesnt execute the next part of the program. Source: CoolInterview.com
Answered by: ganesh kathar | Date: 8/22/2008
| Contact ganesh kathar
More technically - it serves as delimeter for parsing during the parse tree generation which inturn is used during Compilation of code.
Not just C, every language has a predefined char to serve this purpose. Source: CoolInterview.com
Answered by: Nishanth | Date: 8/23/2008
| Contact Nishanth
Well a semicolon represents end of statement,not end of line.Beginners make this mistake by thinking that way.In C a statement does not necessarily mean action(like increment and decrement and so on) statement,even assigning and declaring a variable will be considered as statements.Take a look at this code for(i=0;i<10;i++) { printf("%d",i); } NOTE:1.There is no semicolon after for,because if that's the case the body of loop is not at all executed but a delay takes place,as continuous increment and condition check takes place till the condition fails. 2.i=0 i.e. assign i with zero,is a statement and hence end with ; 3.i<10 a relational statement so end with ; 4.i++ although a statement don't end with semicolon as it is against the syntax of for loop. 5.printf is a statement and hence end with ; Now that's the use of ; but use full stops in English! Source: CoolInterview.com
Answered by: B.N.V.R.Ganesh | Date: 8/30/2008
| Contact B.N.V.R.Ganesh
#include<stdio.h> #include<conio.h> void main() { int a; for(a=1;a<10;a++); { printf("%d",a); } getch(); } /* the above example shows that the use of semicolcon of end of the line. this line print 11 beacuse for loop is terminate at the end of the line. and when the condition is false it print 11 when semicolon is disableafter the for condition it print 1 to 10 thatset. Source: CoolInterview.com
Answered by: ankush | Date: 9/14/2008
| Contact ankush
Semicolon is used in the c language to understand for the compiler that it is the end of the statement . important thing is that semicolon is not used when the conditions are declared i.e., if condition, else condition, for & while conditions . Source: CoolInterview.com
Answered by: pawan | Date: 10/12/2008
| Contact pawan
Semicolon at the end of each statement,take in the case of initialization and declaration statement indicates that it acts as a statement terminator otherwise these statements has got no end point. Source: CoolInterview.com
Answered by: sangitha | Date: 11/16/2008
| Contact sangitha
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|