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("STEAM\n");
    }

    return 0;
}

Sample Output 1

Enter Temperature in Celsius: -5
ICE

Sample Output 2

Enter Temperature in Celsius: 25
WATER

Sample Output 3

Enter Temperature in Celsius: 100
STEAM

Explanation 

  1. The variable temp stores the temperature entered by the user.

  2. The scanf() function reads the temperature in Celsius.

  3. The first if condition checks whether the temperature is less than or equal to 0°C. If true, the program prints ICE.

  4. The else if condition checks whether the temperature is below 100°C. If true, the program prints WATER.

  5. If neither condition is true, the else block prints STEAM.

This program demonstrates the use of the if-else-if decision-making statement in C.

व्याख्या

  1. temp वेरिएबल उपयोगकर्ता द्वारा दर्ज किए गए तापमान को स्टोर करता है।

  2. scanf() फंक्शन Celsius में तापमान इनपुट लेता है।

  3. पहली if कंडीशन जाँचती है कि तापमान 0°C से कम या बराबर है या नहीं। यदि हाँ, तो प्रोग्राम ICE प्रिंट करता है।

  4. else if कंडीशन जाँचती है कि तापमान 100°C से कम है या नहीं। यदि हाँ, तो प्रोग्राम WATER प्रिंट करता है।

  5. यदि दोनों कंडीशन गलत होती हैं, तो else ब्लॉक STEAM प्रिंट करता है।

यह प्रोग्राम C भाषा के if-else-if निर्णय लेने वाले स्टेटमेंट को समझने में मदद करता है।

Note:

This is a simplified educational program based on normal atmospheric pressure. In reality, water can exist as a mixture of phases at the melting and boiling points, and its boiling point changes with pressure.

यह एक सरल शैक्षणिक प्रोग्राम है, जो सामान्य वायुमंडलीय दबाव पर आधारित है। वास्तविकता में गलनांक और क्वथनांक पर पानी की एक से अधिक अवस्थाएँ मौजूद हो सकती हैं, तथा दबाव बदलने पर पानी का क्वथनांक भी बदलता है।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Top High-Paying Tech Skills to Learn in 2025

Complete C Programming Syllabus | Advanced C Roadmap for Students