Few Questions

closed account (N6bRDjzh)
What is transmitted with function call by reference in the programming language C++?

а) the address of the argument
b) the address of the variable
c) if other / what?

What will be done with the following program code in the programming language C ++?

int main ()
int br;
cin>>br;
for (int i=0; i<=n; i++)
{
if (niza[i]==br)
{
cout<<niza[i]<<endl;
break;
}
}

a) linear search
b) sorting with selection
c) if other / what?

Which of the following functions use arguments surrendering only by value in the programming language C++?

a) float g(int a1, int a2, float a)
b) int f1(int &t, int &u, int v)
c) void p(int j, int &f)
d) char znak(int &y, char &b)

What is the result of the following question in the programming language C++?

int a = 100, b = 200;

int *p = &a, *q = &b;

p = q;

a) The value of a goes to b
b) The value of b goes to a
c) The pointer 'p' is going towards a
d) The pointer 'p' is going towards b


Would be grateful if someone helps me with these questions.
Many people here would be happy to help, but can you give your own thoughts first? This looks like a homework problem and we don't like to do homework for people.
closed account (N6bRDjzh)
Well, i'm new to the forum and i would like to apologize, but its not homework. These are questions that i hesitate of. I realize now that i asked them in a form like a homework, meh. Anyways, solved the last one and about the second one, i realized the array and 'n' isn't declared so lets just say it is. I don't know the other ones, that's why i ask. Sorry if i broke some rule.
Last edited on
Please put your code in [code] blocks.
Last edited on
What is transmitted with function call by reference in the programming language C++?

Usually it's the address of the parameter, but that's an implementation detail. For example, it might decide that it can store both the argument and the parameter in a register.

What will be done with the following program code in the programming language C ++?

Look up linear search and selection sort and decide if this code does either one.

Which of the following functions use arguments surrendering only by value in the programming language C++?

If you have a function f() that takes an int parameter. To pass the parameter by value, you declare the function f(int param). To pass the parameter by reference, you declare it f(int &param). It other words, the "&" tells the compiler that you're passing by reference. Given this info you should be able to answer the question.
What is the result of the following question in the programming language C++?

Please read up on the syntax and usage of pointers.

I'm sorry if it seems like I'm being a pain here, but to learn programming, you really do need to understand the stuff. Programming is a skilled craft, sort of like football. And you can't get good at football by having other people practice for you.
Topic archived. No new replies allowed.