First C program
To write the first c program, open the c console and write the program
// My first C program #include <stdio.h>
int main(){
printf("Hello C Language");
return 0;
}
To write the first c program, open the c console and write the program
// My first C program #include <stdio.h>
int main(){
printf("Hello C Language");
return 0;
}
Let us have a look at the elements of above program one by one:
// My first C program
This is a comment. All lines beginning with // are comments. Compiler does not execute comments. Comments are included for short explanations or observations.
#include <stdio.h>
Statements that begin with # (hash) sign are directives for the preprocessor. That means, these statements are processed before compilation takes place. The #include<stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h.
int main()
The main() function is the entry point of every program in c language. Every C program must have a function named main( ). Program execution begins at main( ) and continues by sequentially executing the statements within main( ). A program terminates normally following execution of the last statement of main( ). Every executable statement in C must be terminated by a semicolon ( ; ).
printf()
The printf() function is used to print data on the console.
return 0
The return 0 statement, returns execution status to the OS. The 0 value is used for successful execution and 1 for unsuccessful execution.
How to run and compile the program
There are 2 ways to compile and run the c program, by menu and by shortcut.
By menu
Now click on the compile menu then compile sub menu to compile the c program.
Then click on the run menu then run sub menu to run the c program.
By shortcut
Or, press ctrl+f9 keys compile and run the program directly.
Output
Hello C language
No comments:
Post a Comment