Professional Documents
Culture Documents
Initial Evaluation Test, Introduction To Programming, 2017-2018
Initial Evaluation Test, Introduction To Programming, 2017-2018
Initial Evaluation Test, Introduction To Programming, 2017-2018
2. Is the next C++ code correct? If yes, what will it output? If not, why? (Explain)
#include <iostream>
using namespace std;
void Sum(int y, int x, int& sum) { x=2+x; y=3+x; sum=x+y; }
int main()
{ int a=2; int b=30; int c; Sum(5,5,c); cout<<c; Sum(3,b,c); cout<<c; return
0; }
3. . Is the next C++ code correct? If yes, what will be the value of sum? If not, why? Explain.
int a[] = { 6, 4, 8, 3, 2, 5 }; unsigned int n=4; unsigned int i=1; int sum;
for (sum=10; i < n; ++i) sum -= *(a+i);
4. Which ones from the following code snippets set the variable found as 1, if and only if an element a is
found in the array x with n integers? Circle the right answers.