एक गोले के आयतन और सतह क्षेत्र के लिए, पहले त्रिज्या के मान के साथ एक चर घोषित करें।
int r = 15;
गोले का आयतन प्राप्त करें।
// calculating volume of sphere cal_volume = (4.0 / 3) * (22 / 7) * r * r * r;का आयतन परिकलित करना
अब गोले के पृष्ठीय क्षेत्रफल की गणना की जाती है -
cal_area = 4 * (22 / 7) * r * r;
आइए देखें पूरा कोड -
उदाहरण
using System;
using System.Collections.Generic;
public class Demo {
public static void Main(string[] args) {
double cal_area, cal_volume, r;
// radius
r = 15;
// calculating area of sphere
cal_area = 4 * (22 / 7) * r * r;
// calculating volume of sphere
cal_volume = (4.0 / 3) * (22 / 7) * r * r * r;
Console.WriteLine("Area of Sphere: " + cal_area);
Console.WriteLine("Volume of Sphere: " + cal_volume);
}
} आउटपुट
Area of Sphere: 2700 Volume of Sphere: 13500