Posts

Showing posts with the label If Else Statement

C Program to Find the Roots of a Quadratic Equation द्विघात समीकरण के मूल ज्ञात करने का C प्रोग्राम

A quadratic equation is an equation of the form: द्विघात समीकरण वह समीकरण है जिसका सामान्य रूप इस प्रकार होता है: ax^2+bx+c=0 Here, (a), (b), and (c) are coefficients, and (a) must not be zero. यहाँ (a), (b) और (c) गुणांक हैं तथा (a) का मान शून्य नहीं होना चाहिए। The roots of a quadratic equation can be calculated using the quadratic formula. द्विघात समीकरण के मूल ज्ञात करने के लिए निम्नलिखित सूत्र का उपयोग किया जाता है: [x1=-b+sqrt({b^2-4ac}/{2a}), x2=-b-sqrt({b^2-4ac}/{2a})] Discriminant (विविक्तकर) The discriminant is represented by (D) and is calculated as: विविक्तकर को (D) से दर्शाया जाता है और इसकी गणना इस प्रकार की जाती है: [D=b^2-4ac] The value of the discriminant determines the nature of the roots. विविक्तकर का मान समीकरण के मूलों की प्रकृति निर्धारित करता है। If (D>0): The roots are real and distinct. यदि (D>0), तो मूल वास्तविक और असमान होते हैं। If (D=0): The roots are real and equal. यदि (D=0), तो मूल वास्तविक और समान होते हैं। If (D<0): The roots are complex co...

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