fb popup

/* remove if it's exist in your template */

C Structure

Program:-
 
#include<stdio.h>

void main() { statements; //comments /*comments*/ }

Explanation:-

 main():- When ever a c program starts compiling it firsts go to main and then compile the logical program.But if it compiles the part of main what is the use of the first statement "#include".



Preprocessor and header files:-

Here # is a pre-processor which makes the program to first include the library files and then go for compilation.There are many header files like "stdio.h" which is commonly used in any program as it is standard input and output.That is to include predefined datatypes which are already included in the compiler. "math.h" for including keywords used to do maths like pow,cos,sine,etc

Ex:-scanf(),printf(),etc.

While compiling C program the comments are not compiled or executed.They are only to explain for a layman to understand the line or the logic etc.

The compiler only executes the statements which are within the curly braces({ }).Open brace indicates the start of a program and close brace indicates end of the program.

  If a program is to have only one function then it is to be "main()" as main() is a predefined function.


Void:-

 void indicates nothing i.e no data type and here "void main()" indicates there is no need for a return value to main.

Semicolon:-

 Whenever a semicolon encounters in a program then it indicates the end of the statement.

If we write like this as "main();"-----It indicates the end of main there itself and does not compile the remaining program.

 But now I got a doubt what is a return type.I will explain you that later while we do Functions.Now just remember that return type indicates a return value to the function like "return(5)" then it returns a value 5 to the function.

Comments:-

 A comment can be a single line or a multi line.If we use a single line we should represent it in //...... .If we use more than single line we should represent it in /*.........*/.It is not mandatory to represent single line using //. We can also write the line in multi line comment also, but vice versa is not possible.

Ex:-
Possible

//this is a comment

/*this is a multi line comment in C Program to define the statement written in C language for a                     layman so that he can also understand without any need of knowing how the keyword works*/

/* We can also write single line here*/

Note:-This is not possible

//This is a multi line comment in C Program to define the statement written in C language for a                     layman so that he can also understand without any need of knowing how the keyword works.

No comments:

Post a Comment