First C Program

Let’s write and understand our first simple C program step-by-step. We'll also learn why we use each line.

Example: Simple C Program

#include<stdio.h>      // Standard Input Output header
#include<conio.h>      // Console Input Output header (used for clrscr and getch)

void main() {
    clrscr();           // Clears the output screen (works in Turbo C)
    printf("Hello, World!");  // Prints the message
    getch();            // Waits for a key press before closing the screen
}

How to Save a C Program:

C programs should be saved with a .c extension.
Example: hello.c, program1.c, abc.c

Output:

Hello, From ShikshaSanchar!

Explanation:

  • #include<stdio.h>: This is a header file that allows the use of printf() and scanf() functions.
  • #include<conio.h>: This is an optional header file (mostly used in Turbo C) that provides functions like clrscr() and getch().
  • clrscr();: Clears the screen before printing the output (optional; works in Turbo C).
  • printf();: Used to display output on the screen.
  • getch();: Waits for a key press so that the output window doesn’t close immediately after execution.
  • void main(): Starting point of the program. It can also be written as int main() (standard and recommended).
  • return 0;: Used only when we write int main(). It tells the operating system that the program ended successfully.

Things to Remember:

  • Every C program starts with main() function.
  • Statements inside the function are ended with a semicolon (;).
  • Curly braces { } are used to define the block of code.
  • Header files must be included to use built-in functions like printf().

Note:

  • In modern compilers (like GCC), int main() is preferred and required.
  • conio.h, clrscr(), and getch() may not work in modern compilers like GCC or Code::Blocks. They're mostly used in Turbo C.

Summary:

  • #include<stdio.h>: Required for input-output functions.
  • #include<conio.h>: Used for clrscr() and getch().
  • int main(): Preferred in standard compilers; returns 0 on success.
  • clrscr(): Clears the screen (optional).
  • getch(): Holds the output screen until a key is pressed.
  • File Extension: Save with .c

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar