Posts

C Program to Find Area and Circumference of a Circle वृत्त का क्षेत्रफल एवं परिधि ज्ञात करने का प्रोग्राम

In C language, the area and circumference of a circle can be calculated when its radius is given. The mathematical formulas are used to perform these calculations. सी लैंग्वेज में वृत्त की त्रिज्या (Radius) दी गई होने पर उसका क्षेत्रफल (Area) तथा परिधि (Circumference) ज्ञात की जा सकती है। इनकी गणना के लिए गणितीय सूत्रों का प्रयोग किया जाता है। Formulas सूत्र: Area of Circle = π × r × r Circumference of Circle = 2 × π × r Where r represents the radius of the circle and π (pi) is approximately 3.14. जहाँ r वृत्त की त्रिज्या है तथा π (पाई) का लगभग मान 3.14 लिया जा सकता है। C Program #include <stdio.h> int main(void) { const float pi = 3.14f; float r, area, cir; printf("Enter the radius of a circle: "); scanf("%f", &r); if (r <= 0) { printf("Radius must be a positive value.\n"); } else { area = pi * r * r; cir = 2 * pi * r; printf("Area of circle = %.2f\n", area); ...

C Program to Calculate Addition, Subtraction, Multiplication and Division of Two Numbers दो संख्याओं का जोड़, घटाव, गुणा एवं भाग ज्ञात करने का प्रोग्राम

In C language, arithmetic operators are used to perform mathematical operations such as addition, subtraction, multiplication, and division on two numbers. सी लैंग्वेज में दो संख्याओं पर जोड़, घटाव, गुणा एवं भाग जैसी गणितीय क्रियाएँ करने के लिए अर्थमैटिक ऑपरेटर्स का प्रयोग किया जाता है। Arithmetic Operators अर्थमैटिक ऑपरेटर्स Operator Operation ऑपरेशन + Addition जोड़ - Subtraction घटाव * Multiplication गुणा / Division भाग C Program #include <stdio.h> int main(void) { float a, b, ans; printf("Enter two numbers:\n"); scanf("%f %f", &a, &b); ans = a + b; printf("Addition = %f\n", ans); ans = a - b; printf("Subtraction = %f\n", ans); ans = a * b; printf("Multiplication = %f\n", ans); if (b != 0) { ans = a / b; printf("Division = %f\n", ans); } else { printf("Divisor must be a non-zero value.\n"); } return 0; } Output Ent...

C Program to Find Area of Triangle Using Heron's Formula हेरॉन के सूत्र की सहायता से त्रिभुज का क्षेत्रफल ज्ञात करने का प्रोग्राम

Heron's formula is used to calculate the area of a triangle when the lengths of its three sides are given. हेरॉन के सूत्र का प्रयोग तब किया जाता है जब किसी त्रिभुज की तीनों भुजाओं की लंबाई दी गई हो तथा उसके आधार एवं ऊँचाई की जानकारी उपलब्ध न हो। Heron's Formula हेरॉन का सूत्र The area of a triangle can be calculated using the following formula: त्रिभुज का क्षेत्रफल निम्न सूत्र की सहायता से ज्ञात किया जा सकता है: Area = √[s(s − a)(s − b)(s − c)] Where: a , b , and c are the lengths of the three sides of the triangle. s is the semi-perimeter of the triangle. जहाँ: a , b तथा c त्रिभुज की तीनों भुजाओं की लंबाई हैं। s त्रिभुज का अर्धपरिमाप है। Semi-perimeter: s = (a + b + c) / 2 C Program #include <stdio.h> #include <math.h> int main(void) { float area, a, b, c, s; printf("Heron's Formula\n"); printf("Enter three sides of a triangle:\n"); scanf("%f %f %f", &a, &b, &c); /* Check whether sides can f...

Functions in C Language सी लैंग्वेज में फंक्शन

In C language, a function is a group of programming statements written together to perform a specific task. When a function is called from a program, its statements are executed. This process is known as function calling. सी लैंग्वेज में, फंक्शन स्टेटमेंट्स का एक समूह होता है, जिन्हें किसी निश्चित कार्य को पूरा करने के लिए एक साथ लिखा जाता है। जब किसी प्रोग्राम में फंक्शन को कॉल किया जाता है, तब उसके स्टेटमेंट्स एक्सीक्यूट होते हैं। इस प्रक्रिया को फंक्शन कॉलिंग कहा जाता है। Types of Function फंक्शन के प्रकार There are two types of functions in C language: सी लैंग्वेज में फंक्शन दो प्रकार के होते हैं: 1. Library Function / Built-in Function लाइब्रेरी फंक्शन / बिल्ट-इन फंक्शन Library functions are predefined functions provided by the C standard library or other libraries. These functions perform commonly required tasks, such as input/output operations, mathematical calculations, string handling, and memory management. लाइब्रेरी फंक्शन पहले से परिभाषित फंक्शन होते हैं, जो C की स्टैंडर्ड ...

Self-Referential Structure सेल्फ रेफरेंशियल स्ट्रक्चर

If a structure defines one or more pointer variables of the same structure type as its data members, it is called a self-referential structure. In other words, a self-referential structure contains a pointer member which can point to another structure variable of the same type. यदि एक स्ट्रक्चर अपने डेटा मेंबर्स के रूप में उसी प्रकार के एक या अधिक पॉइंटर वेरिएबल्स रखता है, तो उसे सेल्फ रेफरेंशियल स्ट्रक्चर (Self-Referential Structure) कहा जाता है। दूसरे शब्दों में, सेल्फ रेफरेंशियल स्ट्रक्चर में एक ऐसा पॉइंटर मेंबर होता है जो उसी प्रकार के किसी अन्य स्ट्रक्चर वेरिएबल को पॉइंट कर सकता है। Syntax: struct structure_name { data_type member1; data_type member2; struct structure_name *pointer_name; }; Example: struct node { int info; struct node *link; }; Explanation: In the above example: struct node is a structure type. info is an integer data member. link is a pointer member of type struct node * . link can store the address of another structure variable of type s...

Pointer to 2D Array पॉइंटर टू 2D ऐरे

 A pointer variable which stores the base address (memory address of the first element) of a 2D array is commonly used to access the elements of that array. It is explained as a pointer to 2D array in introductory C programming. एक पॉइंटर वेरिएबल जो 2D ऐरे के बेस एड्रेस अर्थात उसके पहले एलिमेंट का मेमोरी एड्रेस स्टोर करता है, उसे सामान्यतः पॉइंटर टू 2D ऐरे के रूप में समझाया जाता है। Syntax: data_type array_name[row_size][column_size], *pointer_name; pointer_name = &array_name[0][0]; Example: int mat[3][3], *p; p = &mat[0][0]; In the above example, pointer p stores the memory address of the first element of 2D array mat , that is, mat[0][0] . उपरोक्त उदाहरण में पॉइंटर p , 2D ऐरे mat के पहले एलिमेंट अर्थात mat[0][0] का मेमोरी एड्रेस स्टोर करता है। C Program for Pointer to 2D Array #include <stdio.h> #include <conio.h> void main() { int mat[3][3] = { {2, 4, 5}, {1, 0, 1}, {3, 7, 3} }; int *p, i, j; clrscr(); p = ...

Dangling Pointer डेंगलिंग पॉइंटर

A pointer which initially stores the memory address of an object or variable, but after the object is destroyed or the memory is deallocated, the pointer still retains the same address. Such a pointer is called a dangling pointer. सी प्रोग्राम में एक पॉइंटर वेरिएबल जो प्रारंभ में किसी ऑब्जेक्ट या वेरिएबल का मेमोरी एड्रेस स्टोर करता है, परंतु बाद में उस ऑब्जेक्ट के नष्ट हो जाने या मेमोरी डी-एलोकेट हो जाने के बाद भी पॉइंटर में वही पुराना एड्रेस स्टोर रहता है। इस प्रकार के पॉइंटर को डेंगलिंग पॉइंटर (Dangling Pointer) कहा जाता है। A dangling pointer refers to memory that is no longer valid for the original object. If the programmer tries to access or modify the value through this pointer, it results in undefined behavior. It may cause program crashes, unexpected output, or data corruption. डेंगलिंग पॉइंटर ऐसी मेमोरी को पॉइंट करता है जो मूल ऑब्जेक्ट के लिए अब वैलिड नहीं होती है। यदि प्रोग्रामर इस पॉइंटर के द्वारा वैल्यू को एक्सेस या मॉडिफाई करने का प्रयास करता है, तो यह अनडिफाइंड बिहेवियर उ...