Write a c program to find the volume and surface area of a cube


C program for area of a cube


Formula of surface area of cube:
Surface_area = 6 * a2

Formula of volume of cube:
Volume = a3

C code:

#include<stdio.h>

int main(){

    float a;
    float surface_area,volume;

    printf("Enter size of any side of a cube : ");
    scanf("%f",&a);

    surface_area = 6 * (a * a);
    volume = a * a * a;

    printf("Surface area of cube is: %.3f",surface_area);
    printf("\nVolume of cube is : %.3f",volume);

    return 0;
}

Sample output:

Enter size of any side of a cube: 3
Surface area of cube is: 54.000
Volume of cube is: 27.000

No comments:

Post a Comment