Skip to main content

Hello World Program in C

Programming Languages

Welcome to coding world

Hello World Program in C

Here we will write two C programs to display Hello World on the screen. In the first program we are displaying the message using printf function and in the second program we are calling a user defined function and that function displays the Hello World message on the screen.

 Example 1: Displaying Hello World

#include <stdio.h>

int main()

{

   /* printf function displays the content that is

    * passed between the double quotes.

    */

   printf("Hello World");

   return 0;

}

Output:

 

Hello World

1. #include <stdio.h> – This statement tells compiler to include this stdio.h file in the program. This is a standard input output file that contains the definitions of common input output functions such as scanf() and printf(). In the above program we are using printf() function.

 

2. int main() – Here main() is the function name and int is the return type of this function. Every C program must have this function because the execution of program begins with the main() function. The 0 return value of this function represents successful execution of program while the return value 1 represents the unsuccessful execution of program. This is the reason we have return 0; statement at the end of this main function.

 

3. printf("Hello World"); – This function displays the content within double quotes as it is on the screen.

 

4. return 0; – As mentioned above, the value 0 means successful execution of main() function.

Popular posts from this blog

Good Morning Wishes

Explore the beauty of Murree | A memorable tour from Lahore to murree | Tour packing tips

Memorable Murree Getaway As we set off from Lahore, the excitement was palpable. The scenic drive to Murree was breathtaking, with lush green hills and winding roads. After a four-hour journey, we arrived in Murree, and the crisp mountain air invigorated us. We spent the day exploring Mall Road, browsing local shops, and savoring delicious food at restaurants. The stunning views of the hills and valleys left us spellbound. As the sun set, we settled into our cozy hotel, feeling grateful for this escape from the city's hustle. The next day, we visited the iconic Patriata Chair Lift (if operational) and took in the panoramic views. Our hotel's scenic location offered breathtaking sunrises and sunsets. As we reluctantly bid farewell to Murree and headed back to Lahore, memories of our time in the hills lingered. The trip was a perfect blend of adventure, relaxation, and rejuvenation. Highlights: - Scenic drive to Murree - Exploring Mall Road and local cuisine - Breathtaking views ...

Ayeza Khan Bridal collection 2021

Pakistan Showbiz Ayeza khan celebrate 10M on Instagram Ayeza Khan & Danish Taimoor love story