Read a type double number and prints the value of the number cubed. - C Data Type

C examples for Data Type:double

Introduction

Use a function of your own to cube the value and print it.

Demo Code

#include <stdio.h>

double cubed(double n); // prototype declaration for cubed

int main(void){
  double input;//from  w  w w  .jav  a2s . c o  m
  printf("Enter a number to cube: ");
  scanf("%lf", &input);

  printf("%.3f cubed is %.3f\n", input, cubed(input));

  return 0;
}

double cubed(double n){
  return n * n * n;
}

Result


Related Tutorials