Q1141
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
58/59
Page
Pick an option on a question to see the right answer and solution.
Q1141
Open questionSelect an option to see the answer and solution.
Q1142
Open question#include<stdio.h>
int get_max_element(int *arr,int n)
{
int i, max_element = arr[0];
for(i = 1; i < n; i++)
if(arr[i] > max_element)
max_element = arr[i];
return max_element;
}
int get_min_element(int *arr, int n)
{
int i, min_element = arr[0];
for(i = 1; i < n; i++)
if(arr[i] < min_element)
min_element = arr[i];
return min_element;
}
int main()
{
int n = 7, arr[7] = {5,2,4,7,8,1,3};
int max_element = get_max_element(arr,n);
int min_element = get_min_element(arr,n);
printf("%d %d",max_element,min_element);
return 0;
}Select an option to see the answer and solution.
Q1143
Open questionSelect an option to see the answer and solution.
Q1144
Open questionSelect an option to see the answer and solution.
Q1145
Open questionSelect an option to see the answer and solution.
Q1146
Open questionSelect an option to see the answer and solution.
Q1147
Open question| Activity | Starting time | Finish time |
| A1 | 1 | 2 |
| A2 | 2 | 5 |
| A3 | 1 | 5 |
| A4 | 3 | 6 |
| A5 | 6 | 8 |
| A6 | 4 | 9 |
Select an option to see the answer and solution.
Q1148
Open questionSelect an option to see the answer and solution.
Q1149
Open question#include<stdio.h>
int recursive_search_num(int *arr, int num, int idx, int len)
{
if(idx == len)
return -1;
if(arr[idx] == num)
return idx;
return __________;
}
int main()
{
int arr[5] ={1,3,3,3,5},num=2,len = 5;
int indx = recursive_search_num(arr,num,0,len);
printf("Index of %d is %d",num,indx);
return 0;
}
Which of the following recursive calls should be added to complete the above code?Select an option to see the answer and solution.
Q1150
Open questionSelect an option to see the answer and solution.
Q1151
Open question#include<stdio.h>
int get_len(char *s)
{
int len = 0;
while(s[len] != '\0')
len++;
return len;
}
int main()
{
char *s = "lengthofstring";
int len = get_len(s);
printf("%d",len);
return 0;
}Select an option to see the answer and solution.
Q1152
Open questionSelect an option to see the answer and solution.
Q1153
Open questionSelect an option to see the answer and solution.
Q1154
Open questionSelect an option to see the answer and solution.
Q1155
Open questionSelect an option to see the answer and solution.
Q1156
Open questionSelect an option to see the answer and solution.
Q1157
Open questionSelect an option to see the answer and solution.
Q1158
Open questionSelect an option to see the answer and solution.
Q1159
Open questionSelect an option to see the answer and solution.
Q1160
Open question#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node* next;
}*head;
int max_of_two(int a, int b)
{
if(a > b)
return a;
return b;
}
int recursive_get_max(struct Node* temp)
{
if(temp->next == 0)
return temp->val;
return max_of_two(temp->val,recursive_get_max(temp->next));
}
int min_of_two(int a, int b)
{
if(a < b)
return a;
return b;
}
int recursive_get_min(struct Node* temp)
{
if(temp->next == 0)
return temp->val;
return min_of_two(temp->val,recursive_get_min(temp->next));
}
int main()
{
int n = 9, arr[9] ={1,3,2,4,5,0,5,6,7},i;
struct Node *temp, *newNode;
head = (struct Node*)malloc(sizeof(struct Node));
head -> next =0;
temp = head;
for(i=0;i<n;i++)
{
newNode =(struct Node*)malloc(sizeof(struct Node));
newNode->next = 0;
newNode->val = arr[i];
temp->next =newNode;
temp = temp->next;
}
int max_num = recursive_get_max(head->next);
int min_num = recursive_get_min(head->next);
printf("%d %d",max_num,min_num);
return 0;
}Select an option to see the answer and solution.