/*
* 1000+ C programs + tutorials
*
*
* 16_calculate_surface_area_of_shpere.c
*
*
* Created on: Oct 20, 2014
* Author: Code2care.org
*/
#include <stdio.h>
//#include <conio.h>
void main() {
int radius;
float PI = 3.142;
float surface_area_of_sphere;
// clrscr();
printf(" Program to calculate Surface Area of a Sphere : ");
printf("\n\n Enter the Radius of Sphere : ");
scanf("%d", &radius);
surface_area_of_sphere = 4*PI*radius*radius;
printf("\n\n Surface area of Sphere with side as %d = %lf",radius,surface_area_of_sphere);
// getch();
}
-
Output :
Program to calculate Surface Area of a Sphere :
Enter the Radius of Sphere : 3
Surface area of Sphere with side as 3 = 113.112000
Using pow(x,y) function :
#include <stdio.h>
//#include <conio.h>
void main() {
int radius;
float PI = 3.142;
float surface_area_of_sphere;
// clrscr();
printf(" Program to calculate Surface Area of a Sphere : ");
printf("\n\n Enter the Radius of Sphere : ");
scanf("%d", &radius);
surface_area_of_sphere = 4*PI*pow(radius,2);
printf("\n\n Surface area of Sphere with side as %d = %lf",radius,surface_area_of_sphere);
// getch();
}
-
Output :
Program to calculate Surface Area of a Sphere :
Enter the Radius of Sphere : 3
Surface area of Sphere with side as 3 = 113.112000
The best way to learn C programming is to practice more and more of programs .
Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.
BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.