Q941
Open questionSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
1,171
Questions
48/59
Page
Pick an option on a question to see the right answer and solution.
Q941
Open questionSelect an option to see the answer and solution.
Q942
Open questionSelect an option to see the answer and solution.
Q943
Open questionSelect an option to see the answer and solution.
Q944
Open questionSelect an option to see the answer and solution.
Q945
Open questionSelect an option to see the answer and solution.
Q946
Open question#include <stdio.h>
bool func(int arr[], int n, int sum)
{
if (sum == 0)
return true;
if (n == 0 && sum != 0)
return false;
if (arr[n-1] > sum)
return func(arr, n-1, sum);
return func(arr, n-1, sum) || func(arr, n-1, sum-arr[n-1]);
}
int main()
{
int arr[] = {4,6, 12, 2};
int sum = 12;
int n = sizeof(arr)/sizeof(arr[0]);
if (func(arr, n, sum) == true)
printf("true");
else
printf("false");
return 0;
}Select an option to see the answer and solution.
Q947
Open questionSelect an option to see the answer and solution.
Q948
Open questionSelect an option to see the answer and solution.
Q949
Open questionSelect an option to see the answer and solution.
Q950
Open questionSelect an option to see the answer and solution.
Q951
Open questionSelect an option to see the answer and solution.
Q952
Open questionSelect an option to see the answer and solution.
Q953
Open question#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node* next;
}*head;
int linear_search(int value)
{
struct Node *temp = head->next;
while(temp != 0)
{
if(temp->val == value)
return 1;
temp = temp->next;
}
return 0;
}
int main()
{
int arr[5] = {1,2,3,4,5};
int n = 5,i;
head = (struct Node*)malloc(sizeof(struct Node));
head->next = 0;
struct Node *temp;
temp = head;
for(i=0; i<n; i++)
{
struct Node *newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->next = 0;
newNode->val = arr[i];
temp->next = newNode;
temp = temp->next;
}
int ans = linear_search(-1);
if(ans == 1)
printf("Found");
else
printf("Not found");
return 0;
}Select an option to see the answer and solution.
Q954
Open questionSelect an option to see the answer and solution.
Q955
Open questionSelect an option to see the answer and solution.
Q956
Open questionSelect an option to see the answer and solution.
Q957
Open questionSelect an option to see the answer and solution.
Q958
Open questionSelect an option to see the answer and solution.
Q959
Open questionSelect an option to see the answer and solution.
Q960
Open questionSelect an option to see the answer and solution.