Write a program in C language to print "Hello, World!"

Write a program in C language to print "Hello, World!"



Here's a simple C program to print "Hello, World!":

--------------------------------------------------------------------

Code:

#include <stdio.h>

int main() {

    printf("Hello, World!\n");

    return 0;

}

---------------------------------------------------------------------

Output:

Hello, World!

Explanation:

- The `#include <stdio.h>` line includes the standard input/output library, which provides the `printf()` function.

- The `int main()` function is the starting point of the program, where the execution begins.

- The `printf("Hello, World!\n");` statement is used to print the message "Hello, World!" on the console.

- The `\n` is an escape sequence for a newline character, which moves the cursor to the next line after printing the message.

- The `return 0;` statement indicates the successful termination of the `main()` function.

 

To run this program:

  • Save the program with a .c extension (e.g., hello.c).
  • Open a command prompt or terminal and navigate to the directory where the program is saved.
  • Compile the program using a C compiler (e.g., gcc):
  • Run the compiled program:

Congratulations! You have successfully written and executed a "Hello, World!" program in C.

To learn one-to-one C Programming, visit the Academy of Web Technologies and Information Management (AWTIM) or call 08961235337 for details.


Comments