Mac volume of a rectangular prism

sg001

macrumors newbie
Original poster
Jul 30, 2012
9
0
I can't seem to get this code working
and I don't really know what errors I have made?
If someone can have a quick look..


Code:
// math.c                                                      
// Author: Samuel Gilbert
// Date: 31/7/12
// A simple program computing volume, surface area and total length

#include <stdio.h>

int main(int argc, char * argv[]){
   
   float width, length, height, volume, surface area, edge length
   printf("Enter length: ");
   printf("Enter width: ");
   printf("Enter height: n");
   scanf("%f%f%f", &length, &height, &width);
   volume = (width*length*height);
   printf("volume is %.2f cubic meters\n", volume);
   return 0;
}
and after compiling heres what I get
Code:
math.c: In function ‘main’:
math.c:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘area’
cc1: warnings being treated as errors
math.c:14: warning: too many arguments for format
math.c:14: warning: too many arguments for format
Thanks.
 
Last edited by a moderator:

sg001

macrumors newbie
Original poster
Jul 30, 2012
9
0
fixed a little

ok now I have the program working

float width, length, height, volume;
printf("Enter length:\n ");
printf("Enter height:\n ");
printf("Enter width: \n");
scanf("%f %f %f",&length,&height,&width);
volume = (width*length*height);
printf("When length is %.2f, ",length);
printf("When height is %.2f, ",height);
printf("When width is %.2f, ",width);
printf("volume is %.2f cubic meters\n",volume);
return 0;
}

Thanks for the help:)