CPP

CPP

Generalized Numeric Algorithms has 9 Questions

Which header file is used to operate on numeric sequences?

number
numeric
algorithm
None of the mentioned
Which mathematics library is used for vector manipulation in c++?

cli++
vec++
blitz++
None of the mentioned
What is the use of accumulate function in numeric library?

Returns the number
Returns the result of accumulating all the values in the range
Both a & b
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int myop (int x, int y)
  6.     {
  7.         return x + y;
  8.     }
  9.     int main ()
  10.     {
  11.         int val[] = {1, 2, 3, 5};
  12.         int result[7];
  13.         adjacent_difference (val, val + 7, result);
  14.         for (int i = 0; i < 4; i++)
  15.             cout << result[i] <<' ';
  16.         return 0;
  17.     }

1 1 1 2
1 2 3 1
1 2 3 5
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int myop (int x, int y) 
  6.     {
  7.         return x + y + 1;
  8.     }
  9.     int main () 
  10.     {
  11.         int val[] = {1, 2, 3, 4, 5};
  12.         int result[5];
  13.         partial_sum (val, val + 5, result);
  14.         for (int i = 0; i < 5; i++)
  15.             cout << result[i] << ' ';
  16.         return 0;
  17.     }

1 3 6
1 3 6 10 15
1 3 6 10 16
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include 
  4.     using namespace std;
  5.     int myfunction (int x, int y) 
  6.     {
  7.         return x + 2 * y;
  8.     }
  9.     struct myclass 
  10.     {
  11.         int operator()(int x, int y) 
  12.         {
  13.             return x + 3 * y;
  14.         }
  15.     } myobject;
  16.     int main () 
  17.     {
  18.         int init = 100;
  19.         int numbers[] = {10, 20, 30};
  20.         cout << accumulate (numbers, numbers + 3, init, minus<int>() );
  21.         cout << endl;
  22.         return 0;
  23.     }

40
100
140
None of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     #include  
  4.     using namespace std;
  5.     int myaccumulator (int x, int y) 
  6.     {
  7.         return x - y;
  8.     }
  9.     int myproduct (int x, int y) 
  10.     {
  11.         return x + y;
  12.     }
  13.     int main () 
  14.     {
  15.         int a = 100;
  16.         int series1[] = {10, 20, 30};
  17.         int series2[] = {1, 2, 3};
  18.         cout << inner_product(series1, series1 + 3, series2, a ,myaccumulator, 
  19.         myproduct);
  20.         cout << endl;
  21.         return 0;
  22.     }

40
34
32
20
What is the default operation of adjacent_difference function in numeric library?

Difference
Addition
Multiplication
None of the mentioned
How many parameters are available in partial_sum function in c++?

2
3
2 or 3
3 or 4