Sum - C Program
Sum - C Program
Area of a Circle
#include <stdio.h>
#define PI 3.14
int main() {
float radius, area;
printf("Enter radius: ");
scanf("%f", &radius);
area = PI * radius * radius;
printf("Area of Circle = %.2f\n", area);
return 0;
}
✅ 2. Circumference of a Circle
#include <stdio.h>
#define PI 3.14
int main() {
float radius, circumference;
printf("Enter radius: ");
scanf("%f", &radius);
circumference = 2 * PI * radius;
printf("Circumference = %.2f\n", circumference);
return 0;
}
✅ 3. Diameter of a Circle
#include <stdio.h>
int main() {
float radius, diameter;
printf("Enter radius: ");
scanf("%f", &radius);
diameter = 2 * radius;
printf("Diameter = %.2f\n", diameter);
return 0;
}
✅ 4. Area of a Sphere
#include <stdio.h>
#define PI 3.14
int main() {
float radius, area;
printf("Enter radius: ");
scanf("%f", &radius);
area = 4 * PI * radius * radius;
printf("Surface Area of Sphere = %.2f\n", area);
return 0;
}
✅ 5. Volume of a Sphere
#include <stdio.h>
#define PI 3.14
int main() {
float radius, volume;
printf("Enter radius: ");
scanf("%f", &radius);
volume = (4.0 / 3) * PI * radius * radius * radius;
printf("Volume of Sphere = %.2f\n", volume);
return 0;
}
✅ 6. Area of a Hemisphere
#include <stdio.h>
#define PI 3.14
int main() {
float radius, area;
printf("Enter radius: ");
scanf("%f", &radius);
area = 3 * PI * radius * radius;
printf("Surface Area of Hemisphere = %.2f\n", area);
return 0;
}
✅ 7. Volume of a Hemisphere
#include <stdio.h>
#define PI 3.14
int main() {
float radius, volume;
printf("Enter radius: ");
scanf("%f", &radius);
volume = (2.0 / 3) * PI * radius * radius * radius;
printf("Volume of Hemisphere = %.2f\n", volume);
return 0;
}
✅ 8. Volume of a Cylinder
#include <stdio.h>
#define PI 3.14
int main() {
float radius, height, volume;
printf("Enter radius and height: ");
scanf("%f %f", &radius, &height);
volume = PI * radius * radius * height;
printf("Volume of Cylinder = %.2f\n", volume);
return 0;
}
#include <stdio.h>
#define PI 3.14
int main() {
float radius, height, area;
printf("Enter radius and height: ");
scanf("%f %f", &radius, &height);
area = 2 * PI * radius * (radius + height);
printf("Surface Area of Cylinder = %.2f\n", area);
return 0;
}
#include <stdio.h>
#define PI 3.14
int main() {
float radius, height, lateralArea;
printf("Enter radius and height: ");
scanf("%f %f", &radius, &height);
lateralArea = 2 * PI * radius * height;
printf("Lateral Surface Area = %.2f\n", lateralArea);
return 0;
}