Help with some codes

Feb 1, 2016 at 12:15pm
Heloo, can someone help me with these codes please?
all variables are integers.
What will be the answer?
a) 1 3 9 b) 1 2 3 c) 1 10 9

d) 1 10 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  void Twist( int a, int& b )
	{
		int c;
		c = a - 2;
		a = a * 3;
		b = c + a;
	}
        r = 1;
	s = 2;
	t = 3;
	Twist(t, s);
	cout << r << ‘ ‘ << s << ‘ ‘ << t << endl;


Feb 1, 2016 at 12:21pm
Heloo, can someone help me with these codes please?
all variables are integers.
What will be the answer?

Have you heard of these things called compilers? They're great for figuring this sort of thing out. Run the code if you can't logic it out.
Feb 1, 2016 at 12:32pm
There are errors when i want to compile. Can u help me please?
Feb 1, 2016 at 1:37pm
It is clear the code is not in the right form.

Here might be a working code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

using std::cout;
using std::endl;

void Twist(int a, int &b)
{
    int c;
    c = a - 2;
    a = a * 3;
    b = c + a;
}

int main(void)
{
    int r, s, t;
    r = 1;
    s = 2;
    t = 3;
    Twist(t, s);
    cout << r << ' ' << s << ' ' << t << endl;
    return 0;
}
Last edited on Feb 1, 2016 at 1:38pm
Topic archived. No new replies allowed.