Variable Declaration in C language

Introduction

जब हम C language में program लिखते हैं, तो किसी भी variable को use करने से पहले उसे declare करना जरूरी होता है।

Declaration compiler को यह बताता है कि:

  • variable का नाम क्या है
  • उसका data type क्या है

अगर हम बिना declaration के variable का use करेंगे, तो program error देगा।

इसलिए declaration programming का एक बहुत important step है।

Definition

Declaration वह प्रक्रिया है जिसमें variable का नाम और उसका data type बताया जाता है, ताकि compiler उसके लिए memory allocate कर सके।

Example

int a;
float b;
char c;

यहाँ:

  • int, float, char → data types हैं
  • a, b, c → variables हैं

Initialization with Declaration

हम declaration के साथ value भी दे सकते हैं:

int a = 10;
float b = 5.5;

Real World Example

मान लो आप किसी होटल में room book करते हैं:

  • पहले आप बताते हैं कि आपको किस प्रकार का room चाहिए (single, double)
  • फिर आपको room दिया जाता है

इसी तरह:

  • Declaration → room type बताना
  • Memory allocation → room मिलना

Types of Declaration

  1. Simple Declaration
int a;
  1. Multiple Declaration
int a, b, c;
  1. Declaration with Initialization
int a = 10;

Exam Points

  • Variable को use करने से पहले declare करना जरूरी है
  • Declaration data type और variable name बताता है
  • Declaration के समय memory allocate होती है
  • Initialization optional होता है

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top