Posts

C Program to Find Profit, Loss or No Profit No Loss लाभ, हानि या न लाभ न हानि ज्ञात करने का C प्रोग्राम

When a product is purchased at a certain price and sold at another price, we can determine whether a profit or loss has occurred by comparing the cost price and selling price. जब कोई वस्तु एक निश्चित कीमत पर खरीदी जाती है और दूसरी कीमत पर बेची जाती है, तो क्रय मूल्य और विक्रय मूल्य की तुलना करके लाभ या हानि ज्ञात की जा सकती है। Cost Price (CP): The price at which a product is purchased. क्रय मूल्य (CP): वह मूल्य जिस पर कोई वस्तु खरीदी जाती है। Selling Price (SP): The price at which a product is sold. विक्रय मूल्य (SP): वह मूल्य जिस पर कोई वस्तु बेची जाती है। Formulas (सूत्र) Profit (लाभ) = Selling Price − Cost Price , when SP > CP. Loss (हानि) = Cost Price − Selling Price , when CP > SP. No Profit, No Loss (न लाभ, न हानि) , when SP = CP. C Program #include <stdio.h> int main(void) { float sp, cp, pl; printf("Enter Cost Price and Selling Price: "); scanf("%f %f", &cp, &sp); pl = sp - cp; if (pl > 0) { pri...

C Program to Print the State of Water According to Temperature तापमान के अनुसार पानी की अवस्था प्रिंट करने का C प्रोग्राम

Water can exist in three common states: solid (ice), liquid (water), and gas (steam or water vapour). Its state changes according to temperature and pressure. पानी मुख्य रूप से तीन अवस्थाओं में पाया जाता है: ठोस (बर्फ), द्रव (पानी) और गैस (भाप या जलवाष्प)। तापमान और दबाव के अनुसार पानी की अवस्था बदलती है। At normal atmospheric pressure, ice melts at 0°C and water boils at approximately 100°C. This program accepts the temperature in Celsius and displays the corresponding state of water. सामान्य वायुमंडलीय दबाव पर बर्फ 0°C पर पिघलती है और पानी लगभग 100°C पर उबलता है। यह प्रोग्राम Celsius में तापमान इनपुट लेकर पानी की अवस्था प्रदर्शित करता है। C Program #include <stdio.h> int main(void) { float temp; printf("Enter Temperature in Celsius: "); scanf("%f", &temp); if (temp <= 0) { printf("ICE\n"); } else if (temp < 100) { printf("WATER\n"); } else { printf("STEA...

C Program to Calculate Gross Salary of an Employee कर्मचारी का सकल वेतन ज्ञात करने का प्रोग्राम

In C language, the gross salary of an employee can be calculated by adding the basic salary and various allowances such as Travel Allowance (TA), Dearness Allowance (DA), and House Rent Allowance (HRA). सी लैंग्वेज में कर्मचारी का सकल वेतन (Gross Salary) ज्ञात करने के लिए मूल वेतन (Basic Salary) में विभिन्न भत्तों जैसे यात्रा भत्ता (TA), महँगाई भत्ता (DA) तथा मकान किराया भत्ता (HRA) को जोड़ा जाता है। Formula सूत्र: For this program, assume that: DA = 25% of Basic Salary TA = 20% of Basic Salary HRA = 10% of Basic Salary Gross Salary = Basic Salary + TA + DA + HRA इस प्रोग्राम में मान लिया गया है कि DA मूल वेतन का 25%, TA मूल वेतन का 20% तथा HRA मूल वेतन का 10% है। C Program #include <stdio.h> int main(void) { float gs, bs, ta, da, hra; printf("Enter basic salary: "); scanf("%f", &bs); da = (25 * bs) / 100; ta = (20 * bs) / 100; hra = (10 * bs) / 100; gs = bs + ta + da + hra; printf("\nBasic Salary = %.2f\n", b...

C Program to Find Square, Cube and Square Root of a Number किसी संख्या का वर्ग, घन एवं वर्गमूल ज्ञात करने का प्रोग्राम

In C language, mathematical functions are used to calculate the square, cube, and square root of a number. The pow() function calculates powers, while the sqrt() function calculates the square root. सी लैंग्वेज में किसी संख्या का वर्ग, घन तथा वर्गमूल ज्ञात करने के लिए गणितीय फंक्शन्स का प्रयोग किया जाता है। pow() फंक्शन किसी संख्या की घात ज्ञात करता है, जबकि sqrt() फंक्शन वर्गमूल ज्ञात करता है। Formulas सूत्र: Square (वर्ग): (n^2 = n \times n) Cube (घन): (n^3 = n \times n \times n) Square Root (वर्गमूल): (\sqrt{n}) C Program #include <stdio.h> #include <math.h> int main(void) { float n, square, cube, sr; printf("Enter a number: "); scanf("%f", &n); square = pow(n, 2); cube = pow(n, 3); printf("Square of %.2f = %.2f\n", n, square); printf("Cube of %.2f = %.2f\n", n, cube); if (n >= 0) { sr = sqrt(n); printf("Square root of %.2f = %.2f\n", n, sr); } else...

C Program to Swap Values of Two Variables Without Using a Third Variable तीसरे वेरिएबल का प्रयोग किए बिना दो वेरिएबल्स की वैल्यू स्वैप करने का प्रोग्राम

In C language, swapping means exchanging the values of two variables. We can swap two numerical variables without using a third variable by applying addition and subtraction operations. सी लैंग्वेज में स्वैपिंग का अर्थ दो वेरिएबल्स की वैल्यू को आपस में बदलना होता है। जोड़ तथा घटाव की गणितीय क्रियाओं का प्रयोग करके तीसरे वेरिएबल के बिना भी दो संख्यात्मक वेरिएबल्स की वैल्यू स्वैप की जा सकती है। C Program #include <stdio.h> int main(void) { float a, b; printf("Enter two values:\n"); scanf("%f %f", &a, &b); printf("Before swapping: a = %.2f, b = %.2f\n", a, b); a = a + b; b = a - b; a = a - b; printf("After swapping: a = %.2f, b = %.2f\n", a, b); return 0; } Output Enter two values: 10 20 Before swapping: a = 10.00, b = 20.00 After swapping: a = 20.00, b = 10.00 Explanation व्याख्या Suppose a = 10 and b = 20 . The following operations swap their values: मान लीजिए a = 10 तथा b = 20 हैं। निम्...

C Program to Swap Values of Two Variables Using a Third Variable तीसरे वेरिएबल की सहायता से दो वेरिएबल्स की वैल्यू स्वैप करने का प्रोग्राम

In C language, swapping means exchanging the values of two variables. A third variable is used temporarily to store one value so that the original value is not lost during the exchange. सी लैंग्वेज में स्वैपिंग का अर्थ दो वेरिएबल्स की वैल्यू को आपस में बदलना होता है। इस प्रक्रिया में एक तीसरे वेरिएबल का प्रयोग किसी एक वैल्यू को अस्थायी रूप से स्टोर करने के लिए किया जाता है, ताकि वैल्यू बदलते समय मूल मान नष्ट न हो। C Program #include <stdio.h> int main(void) { float a, b, c; printf("Enter two values:\n"); scanf("%f %f", &a, &b); printf("Before swapping: a = %.2f, b = %.2f\n", a, b); c = a; a = b; b = c; printf("After swapping: a = %.2f, b = %.2f\n", a, b); return 0; } Output Enter two values: 10 20 Before swapping: a = 10.00, b = 20.00 After swapping: a = 20.00, b = 10.00 Explanation व्याख्या: Suppose a = 10 and b = 20 . The following statements exchange their values: मान लीजिए a = 10 तथा b = 2...

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); ...