8 Replies - 461 Views - Last Post: 16 August 2009 - 03:12 PM Rate Topic: -----

#1 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

New program

Post icon  Posted 16 August 2009 - 04:33 AM

Hello everyone. I am making a program that will tell me the phone number of a person. All I know for now is that I gotta write this:
#include <iostream>

using namespace std;

int main()
{
  int Grandmother = 6231303
  int Ron = 6236768
  int Guy = 6230219

  cout<<"Who's phone number did you forget: ";


Any idea what to write next?
Is This A Good Question/Topic? 0
  • +

Replies To: New program

#2 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: New program

Posted 16 August 2009 - 04:40 AM

It would be a lot easier if you made an array of names and phone numbers so that the program can search the array for the specified person and, when found, display the phone number.

There are several ways to approach the problem, depending on how much you know about c++. The simplest would be to use two arrays -- a character array to hold names and an int array to hold phone numbers.
Was This Post Helpful? 0
  • +
  • -

#3 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: New program

Posted 16 August 2009 - 04:51 AM

View PostAncient Dragon, on 16 Aug, 2009 - 03:40 AM, said:

It would be a lot easier if you made an array of names and phone numbers so that the program can search the array for the specified person and, when found, display the phone number.

There are several ways to approach the problem, depending on how much you know about c++. The simplest would be to use two arrays -- a character array to hold names and an int array to hold phone numbers.


Can you write a sample code of how to do it?

And by the way, what command tells what the person entered??
Was This Post Helpful? 0
  • +
  • -

#4 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: New program

Posted 16 August 2009 - 04:57 AM

>>Can you write a sample code of how to do it?
#include <string>
...
...
std::string names[20]; // array to hold up to 50 names
int numbers[50]; // phone numbers

names[0] = "Grandmother";
names[1] = "Ron";

numbers[0] = 6231303;
numbers[1] = 6231304;




>>And by the way, what command tells what the person entered??
cin
std::string inputname;
cin >> inputname;


Was This Post Helpful? 0
  • +
  • -

#5 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: New program

Posted 16 August 2009 - 05:08 AM

View PostAncient Dragon, on 16 Aug, 2009 - 03:57 AM, said:

>>Can you write a sample code of how to do it?
#include <string>
...
...
std::string names[20]; // array to hold up to 50 names
int numbers[50]; // phone numbers

names[0] = "Grandmother";
names[1] = "Ron";

numbers[0] = 6231303;
numbers[1] = 6231304;




>>And by the way, what command tells what the person entered??
cin
std::string inputname;
cin >> inputname;


I'm sorry but can you write the whole code... so I know where everything goes and stuff (thanks).
Was This Post Helpful? 0
  • +
  • -

#6 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: New program

Posted 16 August 2009 - 05:58 AM

View Posttomfable, on 16 Aug, 2009 - 04:08 AM, said:

I'm sorry but can you write the whole code... so I know where everything goes and stuff (thanks).


I'm afraid not -- forum rules do not allow me to just "give" you all the code for your homework. Part of your learning process is making mistakes. You will learn a lot more if you code it yourself and make your own mistakes than you would if I just wrote the program for you.
Was This Post Helpful? 0
  • +
  • -

#7 tomfable  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 07-April 09

Re: New program

Posted 16 August 2009 - 02:33 PM

View PostAncient Dragon, on 16 Aug, 2009 - 04:58 AM, said:

View Posttomfable, on 16 Aug, 2009 - 04:08 AM, said:

I'm sorry but can you write the whole code... so I know where everything goes and stuff (thanks).


I'm afraid not -- forum rules do not allow me to just "give" you all the code for your homework. Part of your learning process is making mistakes. You will learn a lot more if you code it yourself and make your own mistakes than you would if I just wrote the program for you.

Wiat, why homework? I am 12 I am just learing C++ by myself. Well, if you can't give me the code, can't you at least tell me where they all go?
Was This Post Helpful? 0
  • +
  • -

#8 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: New program

Posted 16 August 2009 - 02:37 PM

>>I am 12
You should be outside interacting with other children your own age instead of sitting behind a computer all by yourself.


put the code it in main()
#include <string>

int main()
{
   // put your code here

}


This post has been edited by Ancient Dragon: 16 August 2009 - 02:41 PM

Was This Post Helpful? 0
  • +
  • -

#9 debjit625  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 51
  • View blog
  • Posts: 446
  • Joined: 06-September 08

Re: New program

Posted 16 August 2009 - 03:12 PM

Hi it nice that you are 12 and interested in programing.I could give you the code but after that you will have some 100's of questions so i can tell you from where you can learn programing by yourself.Just go to microsoft,s website and search for "C++ A Beginner,s Guide by Herbert Schildt" you can learn a lot from that.They also have some video tutorials watch them also
But one thing learning C or C++ at this age might be hard so for starting you can learn C# (C Sharp) after that you can learn C/C++ easily.
A link for you
http://msdn.microsof...401(en-us).aspx

Good luck :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1