Algorithm
- Print Hello World.
- Use the
printf()
function to print any string. - Add New Line After String to Avoid Presentational Error in some online programming judge.
return
Code Examples
#1 Basic Hello World Code
Code -
C Programming
#include <stdio.h>
int main() {
printf("Hello World");
}
Copy The Code &
Try With Live Editor
Output
#2 Complete Hello World Example
Code -
C Programming
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
Copy The Code &
Try With Live Editor
Output
Demonstration
Why This Hello World
Hello World is the First Program of any programming language how a developer start his programming life. It means - Say the world, Hello and expressing them that - you're coming...
That's Hello World. It's also my first coding.
Demonstration Code Line By Line
We'll demonstrate this code line by line -
First Line,
#include<stdio.h>
We've include/import the standard header library of C programming. It's necessary to print and read. That means to print, we need to use printf() function, which function is declared in this header library file. That's why we need to import this stdio.h
.
Next,
int main(){
//
}
In C programming, C program execute first on entring it's main() function. Whatever, written inside this main function, it'll be execute this.
Next, printf() function, as we've told that we've imported stdio.h header file for this.
printf("Hello World");
Inside printf() function, we've to pass any string. We've passed Hello World there. We could print also variables using this.
Next, return
return 0;
When C progrm finds this return 0, it executed and code will be finished processing. It's not only for C programming, it's for almost every programming language.
Buy C Programming Books