c
c
Accept dimensions of a cylinder and print the surface area and volume (Hint:
surface area =2πr2 + 2πrh, volume = πr2h)
#include <stdio.h>
void main()
{
float radius, height;
float surface_area, volume;
printf("Enter value for radius and height of a cylinder : \n");
scanf("%f%f", &radius, &height);
surface_area = 2 * (22 / 7) * radius * (radius + height);
volume = (22 / 7) * radius * radius * height;
printf("Surface area of cylinder is: %f", surface_area);
printf("\n Volume of cylinder is : %f", volume);
}
Output:
Enter value for radius and height of a cylinder :
4
6
Surface area of cylinder is: 240.000000
Volume of cylinder is : 288.000000
Q2. C Program - Accept temperatures in Fahrenheit (F) and print it in Celsius (C)
and Kelvin (K)
#include<stdio.h>
void main()
{
float cel,fer,kel;
cel= (fer-32)/1.8 ;
printf("Celsius = %f \n",cel);
Output:
Enter Temperature in Fahrenheit :56
Celsius = 13.333333
Kelvin = 286.483337