View Single Post
Old 02-03-2004, 11:00 PM   #2 (permalink)
juanvaldes
Banned
 
Location: shittown, CA
You had your quotes on your scanf's in the wrong place. It needs to go:

scanf("format strings", variables);
like so:
scanf("%d", &bob);

Simple typo bug.

fixed code:
Quote:
#include <stdio.h>

main(void)
{
int nRoomLength=0, nRoomWidth=0, nRoomHeight=0;

double dWidthToLength=0 ; /* width/length */

short int nRoomVolume=0 ; /* nRoomWidth * nRoomLength * nRoomHeight*/

unsigned int nRoomArea=0 ; /* nRoomWidth * nRoomLength */

printf("Please enter a value for the room width:");
scanf("%d", &nRoomLength);
printf("Please enter a value for the room length::");
scanf("%d", &nRoomWidth);
printf("Please enter a value for the room height::");
scanf("%d", &nRoomHeight);

dWidthToLength = nRoomWidth / nRoomLength;
nRoomArea = nRoomLength * nRoomWidth;
nRoomVolume = nRoomLength * nRoomWidth * nRoomHeight;
printf("The area of the floor of the room is: %d", nRoomArea);

printf("The volume of the room is: %d", nRoomVolume);

printf("The ratio of the width to the length is: %d", dWidthToLength);
}
and it looks like you have a bug or two left.

bob:~ johnwort$ ./out
Please enter a value for the room width:50
Please enter a value for the room length::50
Please enter a value for the room height::42
The area of the floor of the room is: 2500The volume of the room is: -26072The ratio of the width to the length is: 1072693248

Last edited by juanvaldes; 02-03-2004 at 11:03 PM..
juanvaldes is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73