C First Program

πŸš€ 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;
}
  

Try It Now

πŸ“Œ Explanation of the Code

  • #include <stdio.h>: Adds functionality for input/output, like printf.
  • 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.