Types of Variables in C Language
Types of Variables in C Language
In the C programming language, variables can be classified into several types based on the kind of data they can hold. Here are the commonly used types of variables in C:
1. Integer Variables: Integer variables are used to store whole numbers without decimal places. They can be declared using the `int` keyword. Examples of integer variables are `int age`, `int count`, etc.
2. Floating-Point Variables: Floating-point variables are used to store numbers with decimal places. They can be declared using the `float` or `double` keyword. Examples of floating-point variables are `float height`, `double weight`, etc.
3. Character Variables: Character variables are used to store individual characters. They are declared using the `char` keyword. Examples of character variables are `char grade`, `char symbol`, etc.
4. Array Variables: Array variables are used to store a collection of elements of the same data type. They can be declared by specifying the data type of the elements followed by square brackets `[]`. Examples of array variables are `int numbers[10]`, `char name[20]`, etc.
5. Pointer Variables: Pointer variables are used to store memory addresses. They can be declared by using the `*` symbol after the data type. Examples of pointer variables are `int *ptr`, `float *fptr`, etc.
6. Structure Variables: Structure variables are used to store a collection of different data types grouped together as a single unit. They are declared using the `struct` keyword. Examples of structure variables are `struct student s1`, `struct point p1`, etc.
7. Enumeration Variables: Enumeration variables are used to define a set of named constant values. They are declared using the `enum` keyword. Examples of enumeration variables are `enum color {RED, GREEN, BLUE}`, `enum day {SUNDAY, MONDAY, TUESDAY}`, etc.
These are some of the common types of variables used in the C programming language. Each type has its own specific purpose and usage, allowing programmers to work with different kinds of data effectively.
हिंदी:
सी प्रोग्रामिंग भाषा में, वेरिएबल्स को उनके धारित किए जाने वाले डेटा के प्रकार के आधार पर कई प्रकार में वर्गीकृत किया जा सकता है। यहां सी में प्रयुक्त सामान्य वेरिएबल्स के कुछ प्रकार हैं:
1. पूर्णांक वेरिएबल्स: पूर्णांक वेरिएबल्स दशमलव स्थान के बिना पूर्णांक संख्याएँ संग्रहीत करने के लिए प्रयोग किए जाते हैं। इन्हें `int` कीवर्ड का उपयोग करके घोषित किया जा सकता है। पूर्णांक वेरिएबल्स के उदाहरण हैं `int age`, `int count`, आदि।
2. फ़्लोटिंग पॉइंट वेरिएबल्स: फ़्लोटिंग पॉइंट वेरिएबल्स दशमलव स्थान वाले अंकों को संग्रहीत करने के लिए प्रयोग किए जाते हैं। इन्हें `float` या `double` कीवर्ड का उपयोग करके घोषित किया जा सकता है। फ़्लोटिंग पॉइंट वेरिएबल्स के उदाहरण हैं `float height`, `double weight`, आदि।
3. चारेक्टर वेरिएबल्स: चारेक्टर वेरिएबल्स व्यक्तिगत वर्णों को संग्रहीत करने के लिए प्रयोग किए जाते हैं। इन्हें `char` कीवर्ड का उपयोग करके घोषित किया जा सकता है। चारेक्टर वेरिएबल्स के उदाहरण हैं `char grade`, `char symbol`, आदि।
4. एरे वेरिएबल्स: एरे वेरिएबल्स एक ही डेटा प्रकार के अनुभागों का संग्रह करने के लिए प्रयोग किए जाते हैं। इन्हें उपयोग करके वेरिएबल्स की घोषणा करते समय उनके तत्वों के डेटा प्रकार की स्पष्टीकरण किया जाता है। एरे वेरिएबल्स के उदाहरण हैं `int numbers[10]`, `char name[20]`, आदि।
5. पॉइंटर वेरिएबल्स: पॉइंटर वेरिएबल्स स्मृति पतों को संग्रहीत करने के लिए प्रयोग किए जाते हैं। इन्हें डेटा प्रकार के बाद `*` चिह्न का उपयोग करके घोषित किया जा सकता है। पॉइंटर वेरिएबल्स के उदाहरण हैं `int *ptr`, `float *fptr`, आदि।
6. संरचना वेरिएबल्स: संरचना वेरिएबल्स विभिन्न डेटा प्रकारों के एक एकल इकाई के रूप में एकत्रित किए जाने वाले विभिन्न डेटा प्रकारों को संग्रहीत करने के लिए प्रयोग किए जाते हैं। इन्हें `struct` कीवर्ड का उपयोग करके घोषित किया
जाता है। संरचना वेरिएबल्स के उदाहरण हैं `struct student s1`, `struct point p1`, आदि।
7. गणना वेरिएबल्स: गणना वेरिएबल्स एक सेट के रूप में नामित स्थायी मान्यता मानों को परिभाषित करने के लिए प्रयोग किए जाते हैं। इन्हें `enum` कीवर्ड का उपयोग करके घोषित किया जाता है। गणना वेरिएबल्स के उदाहरण हैं `enum color {RED, GREEN, BLUE}`, `enum day {SUNDAY, MONDAY, TUESDAY}`, आदि।
ये कुछ सामान्यतया सी में प्रयुक्त होने वाले वेरिएबल्स के प्रकार हैं। प्रत्येक प्रकार का अपना विशेष उद्देश्य और उपयोग होता है, जिससे प्रोग्रामर विभिन्न प्रकार के डेटा के साथ सक्रिय रूप से काम कर सकते हैं।
Post a Comment