I HATE PROGRAMMING NEED QUICK HELP!!!!!

thespeakerbox

Platinum Member
Nov 19, 2004
2,654
0
71
I downloaded bloodshed, cause my moron teacher didnt give us anything to go by.
The first day of class and she hands out a paper that says
"write a program to calculate the volume of a box"

I cant get the program to work at all.
I named it a .c file and when i hit compile & run a blank screen comes up.
This is what i have so far.

CAN SOMEONE HELP ME!!!

/*Homework assignment 1 */
/*Compute the volume of a box*/
#include <stdio.h>
void main()
{
int length, width, height;
int volume;
scanf ("%d", &length),
scanf ("%d", &width),
scanf ("%d", &height),
volume= length * width * height;
printf("volume=%d \n ", volume);
}
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
syntax errors.
look up a reference for basic c program structure.
 

AgentEL

Golden Member
Jun 25, 2001
1,327
0
0
wrong forum and you have commas instead of semicolons. how did this compile?
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
Originally posted by: AgentEL
wrong forum and you have commas instead of semicolons. how did this compile?

A comma is a valid operator in C. It has very low precedence. On each side of a comma is an expression and the value of the operation is the value produced by the last expression. The code as shown probably will compile (at least the comma won't produce a compilation error). Is it possible that you're just getting a blank screen because it's waiting for you to enter the data that you're prompting for in the scanf statements?
 

blustori

Senior member
Mar 2, 2005
753
0
0
^ is right. For clarity Why don't you put some printf's before the scanf's, asking the user for the length / width / height.
 

Calin

Diamond Member
Apr 9, 2001
3,112
0
0
Originally posted by: JohnCU
don't you need a SYSTEM("PAUSE"); in there to see the results?

You could run it from a command prompt only, and the result would be there to see. (but your solution is much better).

Anyway, you need to put some printf to explain to the idiot^G^G^G^G^G user what he needs to do.
 

tami

Lifer
Nov 14, 2004
11,588
3
81
don't take a class in programming? it's teachers like yours that prevented many of my friends from pursuing compsci.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: tami
don't take a class in programming? it's teachers like yours that prevented many of my friends from pursuing compsci.

It is not always the teachers. Many times it is stdents that can not grasp and visualize simple problems.

 

purbeast0

No Lifer
Sep 13, 2001
53,656
6,532
126
Originally posted by: EagleKeeper
Originally posted by: tami
don't take a class in programming? it's teachers like yours that prevented many of my friends from pursuing compsci.

It is not always the teachers. Many times it is stdents that can not grasp and visualize simple problems.

like the one that OP posted.

that is easier than 8th grade algebrae.
 

tami

Lifer
Nov 14, 2004
11,588
3
81
Originally posted by: EagleKeeper
Originally posted by: tami
don't take a class in programming? it's teachers like yours that prevented many of my friends from pursuing compsci.

It is not always the teachers. Many times it is stdents that can not grasp and visualize simple problems.

this is true. in my particular case, the professor was forced to resign since there were so many complaints about him. :Q
 

MaxFusion16

Golden Member
Dec 21, 2001
1,512
1
0
Originally posted by: thespeakerbox
I downloaded bloodshed, cause my moron teacher didnt give us anything to go by.
The first day of class and she hands out a paper that says
"write a program to calculate the volume of a box"

I cant get the program to work at all.
I named it a .c file and when i hit compile & run a blank screen comes up.
This is what i have so far.

CAN SOMEONE HELP ME!!!

/*Homework assignment 1 */
/*Compute the volume of a box*/
#include <stdio.h>
void main()
{
int length, width, height;
int volume;
scanf ("%d", &length),
scanf ("%d", &width),
scanf ("%d", &height),
volume= length * width * height;
printf("volume=%d \n ", volume);
}

of course it'll be a blank screen, you are asking the computer to read the user input without asking the user for the input.

this should do it

/*Homework assignment 1 */
/*Compute the volume of a box*/
#include <stdio.h>
void main()
{
int length, width, height;
int volume;
printf("Please enter length, width, and height of the box...\n");
scanf ("%d %d %d", &length, &width, &height);
volume= length * width * height;
printf("volume=%d \n ", volume);
}
 

thespeakerbox

Platinum Member
Nov 19, 2004
2,654
0
71
Er, i figured it out this morning , but thanks for all the help.

Well the story goes that the teacher never ordered our books for the bookstore, and she never wrote anything on the board (Too fat to get up). So we basically had to imagine how everything would look. It was more of a Research assignment. Like, HOW TO GOOGLE "OH MY GOD IM GONNA FAIL C CAUSE MY TEACHERS SO FAT PLEASE LORD TEACH ME CODE"

You get the feel...