1. C Programming for Beginners: Writing Your First Hello World Program in C in 2023 2. Mastering Datatypes in C Programming: A Comprehensive Guide for Beginners in 2023 3. Complete Guide to % Format Specifiers in C for Beginners in 2023 4. A Comprehensive Guide to Operators in C Programming: Learn Everything About Operators in C in 2023 5. Master C Operator Precedence and Associativity in 2023: Definition, Examples, and Code 6. Learn Increment and Decrement Operators in C: A Beginners Guide with Examples - Codzify 7. Mastering Bitwise Operators in C: A Comprehensive Guide with Examples - Codzify 8. Ternary Operators in C Programming: A Beginners Guide (2023) 9. Switch Statements in C 2023: Complete Guide for Beginners 10. Learn Functions in C Programming - A Complete Tutorial for Beginners in 2023 11. Call by Value and Call by Reference in C Programming - A Complete Tutorial for Beginners in 2023 12. Storage Classes in C Programming: A Comprehensive Guide for 2023 13. Arrays in C Programming: A Comprehensive Guide for 2023 14. Basics of 2D Array in C Programming in 2023: Definition, Initialization, and Accessing Elements 15. Beginners Guide to Strings in C Programming with Codes and Examples 16. Strings Functions in C Language - strlen, strcpy,strcmp,strcat functions 17. A Comprehensive Guide to Structures in C Programming in 2023 18. Learn Unions in C Programming with Codes, Examples, and Explanations in 2023 19. Dynamic Memory Allocation in C: Understanding malloc, calloc, realloc, and free Functions 20. Introduction to C Programming 21. Hello world program in C 22. String functions in C - strncat, strcpy, strncpy, strchr, strrchr, strstr functions 23. Program for Fibonacci number in C - Codzify.com 24. What is palindrome number in C? 25. Write a C program to find a factorial of a given number 26. Write a C program to check whether a given number is prime or not 27. Write a C program to check whether a given number is an Armstrong number or not. 28. Write a C Program to transpose a matrix 29. C Programming Tutorial: Understanding Comments and Identifiers with Code Examples 30. Master String Handling Functions in C in 2023 - Codzify Topics

Hello world program in C

Article by: Manish Methani

Last Updated: October 1, 2021 at 2:04pm IST
4 min 23 sec read

There might be two reasons you have landed on this C tutorial for beginners.

1) You might want to explore the basics of C programming.

2) You are looking to write your first hello world program in C.

Trust me learning C programming is the best decision you have ever taken in your life. The skills you need to become the best computer programmer in this world start with C programming. C programming is also called as "Mother of all languages".

We will guide you through each and every concept step by step.  Okay, So lets begin with the very basic C program. Most programming languages like C++, Java adopts syntax of C language. That's why C programming is also called as the mother of all Programming languages.

Basic Syntax


/* Preprocessor Declaration */
/* Main Function */
returntype main() 
{
program statements to be executed.
} 

1) Preprocessor Declaration: This section includes all the necessary libraries required in our C program. These libraries include many functions which we can use in our program and this also makes the life of developers easy.

2) main(): main function is the entry point of the program.

Example :-

Let's write our first hello world program in C which illustrates the syntax of C programming.

/* Hello World program in C */
#include 
#include 
int main()
{  
printf("hello world program in c");  
return 0;  
}

Explanation :-

#include 

stdio.h  is the standard input-output library that contains the functions like printf() which are then used to print the statements in a C  program.

#include 

conio.h is the console input-output library that contains the functions like getch() which is basically used to hold the screen. In the next point, we have explained the purpose of getch() function also.

void main()

The main() function is the entry point of every program in the C language. The void keyword specifies that it returns no value.

printf()

The printf() function is used to print the data on the output console.

getch() 

The getch() function is used to hold the screen unless and until the user presses any key like "Enter" or any key. Try removing getch() in the program and see the effect.

Comments

Comments are used to describe the purpose of statements in the program. It is the best practice to include comments every time you write the program. Suppose there is a team of 20 developers in a company which is working on the same project. Then each and every developer should understand what you have written in your code. This is how comments can be useful in live projects.

/* This is a C Comments Statement */

Example:-

/* C First program Comment */

/* C Libraries */
#include    
#include   

/* Main Function 
void main()
{ 

/* Print the Hello world */ 
printf(" hello world program in c ");  
  
getch();  
}  

What are Identifiers in C?

A C identifier is a name used to identify a variable, function, or any other user-defined item. An identifier in C starts with a letter A to Z, a to z, or an underscore '_' followed by zero or more letters, underscores, and digits (0 to 9). C programming does not allow punctuation characters such as @, $, and % within identifiers. C programming is a case-sensitive programming language. Thus, Programming and programming are two different Identifiers in C.

abc , _abc , abc_123 are valid tokens
whereas,
$abc,#abc,abc$ are not valid tokens . 

Tokens in C

A C program consists of various tokens and token is either a keyword, an identifier, a constant, a string literal, or a symbol. There are 5 tokens in the given example above.

printf                           --> 1st token
(                                --> 2nd token
"Hello world program in C"                 --> 3rd token
)                                --> 4th token
;                                --> 5th token

I hope you have now a better understanding of how to write your very first Hello World program in C.

 

Explore Codzify Courses

PREMIUM

Learn to create the Dating App using No-Code Tool FlutterFlow

Level: Advanced

Course Fees: INR 1299/-

Apply Coupon Code: UNLOCK

4 days 100% Money Back Guarantee

Explore Curriculum
PREMIUM

Flutter Mobile App Development Course

Level: Intermediate

Course Fees: INR 1299/-

4 days 100% Money Back Guarantee

Explore Curriculum
PREMIUM

The Complete Angular Course

Level: Beginners

Course Fees: INR 1299/-

4 days 100% Money Back Guarantee

Explore Curriculum
PREMIUM

Dart Programming for Absolute Beginners

Level: Beginners

Course Fees: INR 1299/-

4 days 100% Money Back Guarantee

Coming Soon
FREE

Next.js course

Level: Beginners

Course Fees: FREE

Start Watching
FREE

Fundamentals of Computer Programming Languages

Level: Beginners

Course Fees: FREE

Start Watching
FREE

Learn HTML, CSS & Bootstrap

Level: Beginners

Course Fees: FREE

Start Watching

Latest Web Stories

1

Learn how to open WhatsApp using FlutterFlow | Step by Step Guide

Test your skills with these expert-led curated
Mock Tests.

C Programming Test

Test your C Programming skills with this comprehensive mock test on C Programming.

Take Test

Flutter Test

Solve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take Test

GATE(CSE) Operating Systems

Solve most asked GATE Questions in Operating Systems and test your Gate Score.

Take Test

HTML,CSS Test

This is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take Test

(GATE CSE) Data Structures & Algorithms Test

Solve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take Test

Download the Codzify
Mobile App


Learn Anytime, Anywhere at your own pace. Scan the QR Code with your Mobile Camera to Download the Codzify Mobile App.

Codzify Mobile App Codzify Mobile App
Codzify Logo

Terms and Conditions    Cookie Policy   Refund Policy   Adsense Disclaimer