C प्रोग्रामिंग भाषा में, हम स्ट्रक्चर्स की मदद से सर्कल का क्षेत्रफल, सिलेंडर का क्षेत्रफल और आयतन ज्ञात कर सकते हैं।
- सर्कल का क्षेत्रफल खोजने के लिए उपयोग की जाने वाली तर्क निम्नानुसार है:
s.areacircle = (float)pi * s.radius * s.radius;
- सिलेंडर का क्षेत्रफल खोजने के लिए उपयोग की जाने वाली तर्क निम्नानुसार है:
s.areacylinder = (float)2 * pi * s.radius * s.line + 2 * s.areacircle;
- सिलेंडर का आयतन खोजने के लिए तर्क है:
s.volumecylinder = s.areacircle * s.line;
एल्गोरिथम
स्ट्रक्चर्स का उपयोग करके सर्कल और सिलेंडर के क्षेत्रफल को अन्य पैरामीटर्स के साथ खोजने के लिए नीचे दिया गया एल्गोरिथम देखें।
चरण 1 - स्ट्रक्चर मेंबर्स डिक्लेयर करें।
चरण 2 - इनपुट वेरिएबल्स डिक्लेयर और इनिशियलाइज़ करें।
चरण 3 - सिलेंडर की लंबाई और त्रिज्या दर्ज करें।
चरण 4 - सर्कल का क्षेत्रफल कंप्यूट करें।
चरण 5 - सिलेंडर का क्षेत्रफल कंप्यूट करें।
चरण 6 - सिलेंडर का आयतन कंप्यूट करें।
उदाहरण
निम्नलिखित C प्रोग्राम स्ट्रक्चर्स का उपयोग करके सर्कल और सिलेंडर के क्षेत्रफल को अन्य पैरामीटर्स के साथ खोजता है:
#include <stdio.h>
struct shape{
float line;
float radius;
float areacircle;
float areacylinder;
float volumecylinder;
};
int main(){
struct shape s;
float pi = 3.14;
// taking the input from user
printf("Enter a length of line or height: ");
scanf("%f", &s.line);
printf("Enter a length of radius: ");
scanf("%f", &s.radius);
// area of circle
s.areacircle = (float)pi * s.radius * s.radius;
printf("Area of circular cross-section of cylinder: %.2f\n", s.areacircle);
// area of cylinder
s.areacylinder = (float)2 * pi * s.radius * s.line + 2 * s.areacircle;
printf("Surface area of cylinder: %.2f\n", s.areacylinder);
// volume of cylinder
s.volumecylinder = s.areacircle * s.line;
printf("volume of cylinder: %.2f\n", s.volumecylinder);
return 0;
}
आउटपुट
Enter a length of line or height: 34 Enter a length of radius: 2 Area of circular cross-section of cylinder: 12.56 Surface area of cylinder: 452.16 volume of cylinder: 427.04