5 Replies - 1221 Views - Last Post: 02 April 2013 - 09:24 PM Rate Topic: -----

#1 Gisengryl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 08-September 12

Simple program not executing correctly in Netbeans.

Posted 01 April 2013 - 08:20 PM

After I clicked the 'Run' button in Netbeans, it will compile and run and then it will stop at this point :

Posted Image

I will have to press any key on the keyboard then it will display the text, but it doesn't allow the user to enter any form of input =/

Posted Image

Any help is appreciated.

#include <stdio.h>
#include <stdlib.h>

int main(void) {

int height, length, width, volume, weight;

printf("Enter height of box: ");
scanf("%d", height);
printf("Enter length of hon: ");
scanf("%d", length);
printf("Enter width of bow; ");
scanf("%d", width);
volume = height * length * width;
weight = (volume + 165) / 156;
printf("Volume Cubic Inches: %d\n", volume);
printf("dimensional weight (pounds): %d\n", weight);

return (0);
    
}


Is This A Good Question/Topic? 0
  • +

Replies To: Simple program not executing correctly in Netbeans.

#2 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: Simple program not executing correctly in Netbeans.

Posted 01 April 2013 - 09:00 PM

The scanf function wants the address of the variable, you can use &. The problem doesn't look like that - though try removing whitespace from the stream with a space before %d.

scanf(" %d", &height);


Was This Post Helpful? 0
  • +
  • -

#3 Gisengryl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 08-September 12

Re: Simple program not executing correctly in Netbeans.

Posted 01 April 2013 - 09:15 PM

View Post#define, on 01 April 2013 - 09:00 PM, said:

The scanf function wants the address of the variable, you can use &. The problem doesn't look like that - though try removing whitespace from the stream with a space before %d.

scanf(" %d", &height);



Oh yeah, missed out the &. I added it in and tried removing the whitespace, strangely it still doesn't work.
Was This Post Helpful? 0
  • +
  • -

#4 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: Simple program not executing correctly in Netbeans.

Posted 01 April 2013 - 10:22 PM

Not familiar with Netbeans but using an external terminal (console window) is suggested here, which would hopefully work as a temporary measure at least.

Programs with the scanf not working properly in NetBeans
Was This Post Helpful? 0
  • +
  • -

#5 Gisengryl  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 08-September 12

Re: Simple program not executing correctly in Netbeans.

Posted 02 April 2013 - 08:09 PM

Oh yeah, the link you gave is very helpful.

The use of the external terminal instead works =)

Tried to rep you, but there is some bug ? The +rep button leads right to the top of the page =/
Was This Post Helpful? 0
  • +
  • -

#6 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1398
  • View blog
  • Posts: 4,873
  • Joined: 19-February 09

Re: Simple program not executing correctly in Netbeans.

Posted 02 April 2013 - 09:24 PM

It's ok thanks had trouble with rep button myself - don't know what's happening.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1