Hi friends ,
I have used the logic below to calculate the cube of a number (whole no. or decimal)
#include <stdio.h>
void main(){
int i=0,n;
float a,b;
printf("Enter the number\n");
scanf("%f",&a);
n=a*a;
do{
b=a*i;
i++;
}while(i<=n);
printf(" The answer is \n%f",b);
}
Iam unable to produce the output at a floating point . For eg: if I/P entered is 3.5 , the O/P comes as 42 but the answer is 42.875 . Can someone help me with this