Help!!

Hey guys,

I am taking an intro to Computer Science and have been doing pretty well so far. Alot of the programming is getting tough as of late and my assignment is to do this:

Write a C++ program that prompts the user to enter an integer x at the keyboard. Your main function should store the user's integer x, then invoke two non-value returning functions as follows:

printVar(x); // Prints the value of x
changeVar(x); // Squares x (x times x), then adds 5 to x
printVar(x); // Prints the new value of x

The printVar function should pass the parameter by value.
The changeVar function should pass the parameter by reference.




Is there any way you guys coul help me this? I am a graphic Designer that needs to take this course as a pre=requisite for an html course which Im pumped up for.

Thanks guys!
this is the tutorial on creating and using functions on this site:
http://www.cplusplus.com/doc/tutorial/functions/

needs to take this course as a pre=requisite for an html course

first time I've heard that you have to learn C++ before you can learn html o_O
I know man! I have to take an Intro to Computer Science class before an HTML class. Kinda crazy.

Thanks for your help!
Actually Computer Science provide the basic foundation for you to build on and that's why you need it. HTML, Android, ASP etc whatever are programming/markup scripting languages etc but they do not differ much from the Comp. Sci. fundamentals (algorithms and data structures appear in my mind)

Of cuz some schools/Unis take short-cut as they just want to churn out enough X-language trained graduates to fulfill workforce requirements.

I am neutral on this issue.
I can understand it's kinda stressful for a newbie to learn call-by-value and call-by-reference, though
these two main function should be helpful..
you should try the rest part by yourself

1
2
3
4
5
6
7
8
9
10
11
void printVar(int x)
{
    cout << "An integer X is:" << x <<endl;
}

void changeVar(int& x)
{

    x = x * x;
    x = x + 5 ;
}
Topic archived. No new replies allowed.