just a bit of help

Apr 7, 2012 at 5:06pm
Ok, ive literally started learning to use C++ today and have bought Herbert Schildts "C++ A Beginners Guide". The book so far is extremely good so far for someone who knows nothing of C++ like me.
As I am away from home I am using the CodeToGo ipad app to do all the examples. I've got to one example which I'm not sure what end result I'm suppose to get. I'm not sure if the CodeToGo app is limited to what it can output but I coded an iteractive program that computes the area of a rectangle and after running it I get an odd result. I assumed the program would allow me to enter values and gain a result but instead its just text with a random result each time.
here's the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* An interactive program that computes
   the are of a retangle.
*/

#include <iostream>
using namespace std;

int main()
{
  int length;
  int width;
  
  cout << "Enter the length: ";
  cin >> length; // input the length
  
  cout << "Enter the width: ";
  cin >> width; // input the width
  
  cout << "The area is ";
  cout << length * width; // display the area
  
  return 0;
}


Am I doing something wrong or not understanding or is it just the limitations of the iPad app.
Many thanks for any help.

Chris
Apr 7, 2012 at 5:08pm
I don't see anything wrong with that program...
Apr 7, 2012 at 5:19pm
CodeToGo passes your code to a website, which compiles and runs it, and passes back the output.

Since you have to have a connection to run it, you might find it easier to just use http://ideone.com which has a box into which you can enter the input, before running it.
Apr 7, 2012 at 5:34pm
I think its the input I' not understanding. Where do I input the length/width?
Apr 7, 2012 at 5:37pm
If you're using ideone.com, there should be a button that says
click here to enter input (stdin) or additional note

Click that and then enter your inputs, separated by a space or newline or something like that.
Apr 7, 2012 at 5:44pm
using Microsofts Visual C++, would it output as a program to enter the values? I couldnt find the button you referred to on ideone.com. as long as I know its just the apps limitations and not that I'm doing anything wrong, I'll be happy.
Apr 7, 2012 at 6:14pm
click here to enter input (stdin) or additional note
It's in blue, directly underneath the big box in the middle of the screen.

If you intend to keep coding, look into using something else. This is not a serious solution.
Last edited on Apr 7, 2012 at 6:14pm
Apr 7, 2012 at 6:22pm
As I said, I'm away from home. I just wanted to make sure I was doing things right before progressing. All the other examples worked fine. I plan on using Microsofts Visual C++ once I'm back home.
Topic archived. No new replies allowed.