Home
About Us
Contact Us
Bookmark
Saved Bookmarks
Current Affairs
General Knowledge
Chemical Engineering
UPSEE
BSNL
ISRO
BITSAT
Amazon
ORACLE
Verbal Ability
→
Algorithms Quiz
→
Analysis Of Algorithms in Algorithms Quiz
→
Can struct be inherited in C++ 14 ?(A) Yes(B) No(C...
1.
Can struct be inherited in C++ 14 ?(A) Yes(B) No(C) Depends(D) None of these
Answer»
Show Answer
Discussion
No Comment Found
Post Comment
Related InterviewSolutions
Below is the code to find maximum subarray sum, with errors (which may results to wrong output) in the statement which is commented on right half after code statement. You need to choose the correct option for which corresponding statement is wrong.#include<iostream>using namespace std;// Function to calculate maximum subarray sumint maxSubArraySum(int a[ ], int size){int max_so_far = a[0];int curr_max = a[0];for (int i = 1; i < size; i++){curr_max = max(a[i], curr_max); // statement 1max_so_far = max(max_so_far, curr_max); // statement 2}return max_so_far;}/* Driver program to test maxSubArraySum */int main(){int a[] = {-2, -3, 4, -1, -2, 1, 5, -3};int n = sizeof(a)/sizeof(a[0]);int max_sum = maxSubArraySum(a, n);cout << "Maximum contiguous sum is " << max_sum;return 0;}(A) Statement 1 and statement 2 both.(B) Statement 1 only.(C) Statement 2 only.(D) Neither statement 1 nor statement 2.
What is the time complexity of below code?// CPP program to find the maximum value// of i*arr[i]#include<bits/stdc++.h>using namespace std;int maxSum(int arr[], int n){// Sort the arraysort(arr, arr + n);// Finding the sum of arr[i]*iint sum = 0;for (int i = 0; i < n; i++)sum += (arr[i]*i);return sum;}// Driven Programint main(){int arr[] = { 3, 5, 6, 1 };int n = sizeof(arr)/sizeof(arr[0]);cout << maxSum(arr, n) << endl;return 0;}(A) O(N)(B) O(logN)(C) O(NlogN)(D) O(N*N)
Below is the code for sum product of two arrays, with some errors (which may lead to wrong output) in some statement. Choose the correct option which having the statement with error.// CPP program to find minimum sum of product// of two arrays with k operations allowed on first array.#include <bits/stdc++.h>using namespace std;// Function to find the minimum productint minproduct(int a[], int b[], int n, int k){int diff = 0, res = 0;int temp;for (int i = 0; i < n; i++) {// Find product of current elements and update result.int pro = a[i] * b[i];res = res + pro;// If both product and b[i] are negative,// we must increase value of a[i] to minimize result.if (pro < 0 && b[i] < 0)temp = (a[i] + 2 * k) * b[i];// If both product and a[i] are negative,// we must decrease value of a[i] to minimize result.else if (pro < 0 && a[i] < 0)temp = (a[i] - 2 * k) * b[i];// Similar to above two cases for positive product.else if (pro > 0 && a[i] < 0)temp = (a[i] + 2 * k); // statement 1else if (pro > 0 && a[i] > 0)temp = (a[i] - 2 * k); // statement 2// Check if current difference becomes higher// than the maximum difference so far.int d = abs(pro - temp);if (d > diff)diff = d;}return res - diff;}// Driver functionint main(){int a[] = { 2, 3, 4, 5, 4 };int b[] = { 3, 4, 2, 3, 2 };int n = 5, k = 3;cout << minproduct(a, b, n, k)<< endl;return 0;}(A) Statement 1 only(B) Statement 2 only(C) Both statement 1 and 2(D) Neither statement 1 nor statement 2
What will be the output of following code :#include <iostream>using namespace std;#define x 5/2.0#define y 3/2.0// Function 1int add(float a, float b){cout << "Function 1";return a + b;}// Function 2int add(double a, double b){cout << "Function 2";return a + b;}// Function 3int add(int a, int b){cout << "Function 3";return a + b;}// Driver Functionint main() {cout << add(x, y) << endl;return 0;}(A) Function 2 4(B) Function 3 4(C) Function 1 4(D) None of these
Which testing technique is used to check if critical functionalities of the program is working fine?(A) Monkey Testing(B) Gorilla Testing(C) Smoke Testing(D) None of the above
Which of the following testing technique follows the concept of Abstraction?(A) White Box Testing(B) Black Box Testing(C) Alpha Testing(D) Coal Testing
Can struct be inherited in C++ 14 ?(A) Yes(B) No(C) Depends(D) None of these
Which of the following are the steps of waterfall model in order?(A) Planning, Communication, Modeling, Construction, Deployment(B) Communication, Planning, Modeling, Construction, Deployment(C) Construction, Planning, Modeling, Communication, Deployment(D) Communication, Construction, Modeling, Planning, Deployment
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies