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
ICESample Output 2
Enter Temperature in Celsius: 25
WATERSample Output 3
Enter Temperature in Celsius: 100
STEAMExplanation
The variable
tempstores the temperature entered by the user.The
scanf()function reads the temperature in Celsius.The first
ifcondition checks whether the temperature is less than or equal to 0°C. If true, the program printsICE.The
else ifcondition checks whether the temperature is below 100°C. If true, the program printsWATER.If neither condition is true, the
elseblock printsSTEAM.
This program demonstrates the use of the if-else-if decision-making statement in C.
व्याख्या
tempवेरिएबल उपयोगकर्ता द्वारा दर्ज किए गए तापमान को स्टोर करता है।scanf()फंक्शन Celsius में तापमान इनपुट लेता है।पहली
ifकंडीशन जाँचती है कि तापमान 0°C से कम या बराबर है या नहीं। यदि हाँ, तो प्रोग्रामICEप्रिंट करता है।else ifकंडीशन जाँचती है कि तापमान 100°C से कम है या नहीं। यदि हाँ, तो प्रोग्रामWATERप्रिंट करता है।यदि दोनों कंडीशन गलत होती हैं, तो
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
Post a Comment