In the previous tutorial, you learned to create your first program in C programming language, in the page, you will learn the basic syntax of C.
#include <stdio.h> and #include <stdlib.h> are statement written down to include stdio and stdlib header file that will allow you to get the user input from keyboard and display text on the screen.
C program will start from the main nethod;
int main(int argc, char *argv[])
{
// C statements
}
**Return 0; statement will tell the operating system that your program ends here without any error. a value that is not zero represents the abnormal program temination.
**printf is a commend used to prirnt text on the screen.
Comments
Like other language, in C programming language, comments are used to explain the code written or to exclude the part of code from being excuted.
There are two types of comments C programming:
1.. To make comments for a single line, you will see the // sign. you can place only a single line of text after the single line comments sign. for the normal text, it should be the description of the code. if you place a line of code after single comments, the code won't be executed.
2.. To make comments for multiple lines, you will place the text or code in the /*...*/ block.
See the example below:
#include <stdio.h>
#include <stdlib.h>
/* Your first program will print the words Hello World on the screen.*/
int main(int argc, char *argv[])
{
printf("Hello World\n")//print Hello world on the screen.
system("pause");
return 0;
}
The Result
0 comments:
Post a Comment