Beginner Coder here :( and being the only girl in my class doesn't help because the teacher never helps me

Can someone help me find the solutions to the questions below?

1. Declare and initialize two ints yourPlace and myPlace. Make a pointer to each. Clearly print in table format:
a. the address of each int and the value of their pointers.
b. Each pointer, the dereferenced address of each pointer, and the address of each dereferenced pointer.

2. Declare an array, called squoosh, of ten floats. In tabular form print the address of each float right next the float itself. Then print squoosh (without a subscript), and right next to it print *squoosh.

3. Calculate the average of a number and its square in two different ways:
Via a regular ole function call
Via a function that accepts a pointer and changes the value of the input

4. Create an array of 3 digits numbers and send it to a function. The function should receive it using pointer notation. Also using pointer notation print out each number that has an odd middle digit.

7. Make a madlibs game: Ask the user to enter five nouns, five verbs, and five adjectives/adverbs. The words for each grammar category should be stored in their own array of strings. Write a clever little story with some blanks in it, into which the input words will be inserted at random.

8. Use cin.getline to store a sentence. (cin alone will quit recording after a space.) Create and print a new string that replaces any stars (*) in the original string with the string Frankenstein. Creating a new string is required.

9. Make a menu-driven interface that can do the following after receiving an input sentence. You must use function pointers. You should make use of string.h functions.
Find how many words are in the sentence.
Print a list of the number of letters in each word.
Check to see if any words are repeated.
Make a string out of every other word.
Hello,

I am also a beginner "coder" and even I know that just plainly copy+pasting your hw assignment here is pathetic. No one is just simply going to do your hw for you. You must at least show effort and have some (if not all) of your assignments started and give others something to look at when they try to help you.


Not trying to sound harsh. Just looking out for you.

Sincerely,
A beginner Coder
But it's so hard :(
ww is more or less correct, even if he was brutish in how he expressed it. Unfortunately, programmers tend to be jerks, because they expect people to put a lot of effort into things, and even if you have, if they don't feel you put enough in they'll be rude.

Unfortunately, your homework is a "I've been paying attention in class" kind of homework... So it really is impossible to help much without just giving you the answers.

Remember, that to declare a variable with a value, you do something like:

int age = 12;

A pointer to 'age':

int* pointer_to_age = &age;

Print the pointer's value (which is the address of the variable 'age'):

cout << pointer_to_age;

Print the value in 'age':

cout << age;
or
cout << *pointer_to_age;

Create an array:

int primes[ 3 ] = { 2, 3, 5, 7 };

Read about functions here:
http://www.cplusplus.com/doc/tutorial/functions/

Remember that an array decomposes to a pointer at the first opportunity, so to send an array to a function you must pass both its address and its length:

int sum( int* xs, unsigned size ) { ... }

1
2
int xs[] = { 1, 2, 3, 4 };
cout << sum( xs, 4 ) << "\n";

Just keep working your way through things.


There is no simple answer here. Learning to program is a lot like learning how to ride a bicycle -- you have to keep getting on and trying. It is hard. But it is doable.

(Another unfortunate is that programmers tend to be men, and a lot of them are fairly bigoted... Does your school have a help center?)
Hi,

First of all, i suggest you to read some c++ tutorials :
some beginner - friendly are :

http://www.cplusplus.com/doc/tutorial/
http://www.learncpp.com/

now, regarding the questions, it is pretty straightforward, all you need to know are pointer syntax's , which you can learn here :
http://alumni.cs.ucr.edu/~pdiloren/C++_Pointers/

or if you don't like those funny examples in that site, LOL, here is another:
http://www.learncpp.com/cpp-tutorial/68-pointers-arrays-and-pointer-arithmetic/

~~~~~~~~~~~~~~

i'm going to help you w/ the first few questions, the rest are for you to work w/

Declare and initialize two ints yourPlace and myPlace.
1
2
//-- this is just a simple instruction :
int yourPlace, myPlace;


Make a pointer to each
1
2
3
4
int yourPlace, myPlace;
//-- now we will declare two pointers that point to yourPlace and myPlace
int* pYourPlace = &yourPlace; //-- 'p' prefix means that it is a pointer
int* pMyPlace   = &myPlace;  // this assignment means store the address or the right value to the pointer 


Clearly print in table format:
a. the address of each int and the value of their pointers.
1
2
3
4
5
//-- This is just a simple i/o w/ some additional operators :
//---<address of variable>-----<value of pointer>

cout << &yourPlace << " " << pYourPlace << endl; // '&' means "address of"
cout << &myPlace   << " " << pMyPlace    << endl;


b. Each pointer, the dereferenced address of each pointer, and the address of each dereferenced pointer.
this question is i think misconstructed the address of a pointer cannot be dereferenced, but rather pointer itself, anyway, i'll answer what i think it should be:
1
2
cout << *pYourPlace << " " << &pYourPlace;
cout << *pMyPlace  <<  " " << &pMyPlace;
codergirl123 Duoas Wasn't trying to sound mean or rude. Was just stating the obvious. Now I know maybe I didn't say it in the kindest of ways either, but still... and also I am definitely not a bigot as I myself am also just learning to program and write code.
It just pains me to see when beginners like us just plainly paste their hw here and expect answers from others. You can't just buy a gym membership, hire a trainer, and expect to get a six pack. You have put in some effort, even if it is minimal.

So, I am sorry if you felt insulted or demotivated by what I said earlier. Was just trying to look out for you! :)
Last edited on
But it's so hard :(


@Codegirl123 - you just need to sit down and start learning the language, when you do start to understand, it will get easier, until then it will appear hard. We all have to learn, and there's no alternative to hard work. It will pay off in the long run.
Topic archived. No new replies allowed.