Variables In C In Hindi

📔 : C 🔗

variable किसी memory को दिया गया नाम है जो कि किसी value को Hold करती है या store करती है। मतलब जब हम Variable define कर रहें है तो हम memory में value को store करके उसे नाम दे रहे होते हैं। इसलिए variables को named storage भी कहते हैं।

C Variable

C define a variable

C language में variables को उसके data type के साथ define किया जाता है , जिससे पता चल सके कि define किया जाने वाला variable किस type की value hold करेगा। जैसा कि ऊपर दी गयी image में देख पा रहे हैं।

एक variable का name letters, numbers and underscore Character से बना हो सकता है। variables का name या तो एक letter या underscore से start होना चाहिए।

int age = 24;

C में variables PHP , Python , JavaScript से थोड़ा different तरीके से define किया जाता है , C में variables को उनके data types के साथ define किया जाता है , जैसा कि आप example में देख सकते हैं।

C Variable types and their description

C में different types के variables होते है, example के लिए:

  1. int : integers store करता है (whole numbers), decimals के बिना, जैसे 123 या -123।

  2. double : floating-point numbers store करता है, decimals के साथ, जैसे कि 19.99 or -19.99।

  3. char : single characters store करता है, जैसे 'A' or 'B'। Char values singlr quotes से घिरे होते हैं।

  4. string : text store करता है, जैसे "Hello World"। String values double-quotes से घिरे हैं।

  5. bool : दो states के साथ value को store करता है: true or false।

nt number = 5; // integer variable
  char ch = 'a';  // character variable
  double marks ; 34.56; // for float values. 


// Now let see some common mistakes while defining variables : 
int number = 5;
number = 90.56; Error

Declare Multiple Variables

हालाँकि आप चाहे तो same type के variables को एक single statement / line में भी define कर सकते हैं।

int a = 15, b = 36, c = 20;

C Variable Names

C language में variable define करते समय कुछ बातें आपको ध्यान में रखनी हैं -

  1. variable name में सिर्फ letters, digits और underscores हो कोई भी special characters (@, # , $ etc.) नहीं होने चाहिए है।

  2. variable नाम किसी letter और underscore (_) से ही start होना चाहिए।

  3. C language में variables name case sensitive हैं मतलब age , Age & aGe तीन अलग - अलग variables हैं।

  4. variable का नाम C language में defined किसी भी keywords (like : int , function , include etc.) से match नहीं होना चाहिए।

Important !

आप same variable को एक से ज्यादा बार define नहीं कर सकते हैं , हालाँकि आप उस variable की value change कर सकते हैं।

CopyFullscreenClose FullscreenRun
#include <stdio.h>      
int main() {
  int age = 34;
  int age = 45;
  return 0;
}
Output
In function 'main':
error: redefinition of 'age'
4 |   int age = 45;
  |       ^~~
/tmp/BYJLDHSQH7.c:3:7: note: previous definition of 'age' was here
3 |   int age = 34;
  |       ^~~

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers