C First Program
Example
First program of c programming language.
#include <stdio.h> int main() { printf("Hello World!"); return 0; }
Output:
Hello World!
Breakdown Of Above C Code
The above code is a simple C program that prints “Hello World!” to the console.
-
#include <stdio.h>
: This line is a preprocessor directive that includes the standard input-output library (stdio.h
) in our program. This library provides functions likeprintf
for input and output operations. -
int main() { }
: This is the main function of the program. It serves as the entry point, where the execution of the program begins. Theint
beforemain
indicates that the function returns an integer value. -
printf("Hello World!")
: Theprintf
function is used to print text to the console. In this case, it prints the string “Hello World!”. The string is enclosed in double quotes. -
return 0
: Thereturn
statement ends themain
function and returns the value0
to the operating system. It indicates a successful execution of the program.
When you run above c program, it will output “Hello World!” to the console.
This is a common introductory program that demonstrates the basic structure of a C program.
It show how to use the printf
function for output.
Basic C Program Tips:
- Every C program should have a single main function.
- C program execution starts from the main function.
- The execution of a C program begins at the opening brace of the function and ends at the closing brace.
- Lowercase letters are generally used for writing statements in C.
- Uppercase letters are used for symbolic names, output strings, and messages.
- Every C statement must end with a semicolon.
- Variables must be declared with their respective data types before use.
- C is a free-form language, allowing flexibility in code formatting.
- Comments can be inserted anywhere in a C program, but nested comments are not supported.
- Braces are commonly used for grouping statements in C.