π Your First C Program – Hello, C!
Welcome to the world of C programming! π Let’s begin our journey by writing a simple program that prints a message to the screen. This is like saying hello to the C language itself!
π What Does a Basic C Program Look Like?
Here’s what every C program needs:
#include <stdio.h>
β tells the program to include the Standard Input Output library.int main()
β the starting point of the program.printf()
β used to display text.return 0;
β ends the program properly.
π Example: Hello World in C
This simple program prints “Hello, C Programmers!” to the screen. Let’s see it in action:
#include <stdio.h> int main() { printf("Hello, C Programmers!\\n"); return 0; }
π Explanation of the Code
#include <stdio.h>
: Adds functionality for input/output, likeprintf
.int main()
: The main function where the program begins.printf()
: Prints text to the screen.\\n
moves the cursor to a new line.return 0;
: Indicates that the program ran successfully.
π‘ Fun Tip
Try changing the message inside printf()
to your own name or something fun, like:
printf("I love pizza and C programming!\n");
π§ Practice Challenge
Modify the program to print 3 different lines of text. For example:
Welcome to C! This is my first program. Let's code and have fun!
π You’re on Your Way!
That’s it! You’ve written your first C program. π Keep experimenting, and donβt worry if you make mistakes β itβs all part of learning.