c8
This commit is contained in:
25
C8/ex7.c
Normal file
25
C8/ex7.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main() {
|
||||
int rc; // used to check return codes of scanf
|
||||
float radius, height;
|
||||
|
||||
printf("Enter radius: ");
|
||||
rc = scanf("%f", &radius);
|
||||
// scanf returns number of scanned items
|
||||
if (rc != 1) {
|
||||
printf("Please enter an positive real integer or decimal\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Enter height: ");
|
||||
rc = scanf("%f", &height);
|
||||
// scanf returns number of scanned items
|
||||
if (rc != 1) {
|
||||
printf("Please enter an positive real integer or decimal\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Surface area: %f\n", 2*M_PI*radius*radius + 2*M_PI*radius*height);
|
||||
}
|
||||
Reference in New Issue
Block a user