Q961
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
49/59
Page
Pick an option on a question to see the right answer and solution.
Q961
Open questionSelect an option to see the answer and solution.
Q962
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 recursive_search_num(arr, num, idx+1, len);
}
int main()
{
int arr[8] ={1,2,3,3,3,5,6,7},num=5,len = 8;
int indx = recursive_search_num(arr,num,0,len);
printf("Index of %d is %d",num,indx);
return 0;
}Select an option to see the answer and solution.
Q963
Open questionSelect an option to see the answer and solution.
Q964
Open question#include<stdio.h>
int recursive_sum(int n)
{
if(n == 0)
return 0;
return n + recursive_sum(n - 1);
}
int main()
{
int n = 5;
int ans = recursive_sum(n);
printf("%d",ans);
return 0;
}Select an option to see the answer and solution.
Q965
Open questionSelect an option to see the answer and solution.
Q966
Open questionSelect an option to see the answer and solution.
Q967
Open question#include<stdio.h>
int sum_of_digits(int n)
{
int sm = 0;
while(n != 0)
{
_________;
n /= 10;
}
return sm;
}
int main()
{
int n = 1234;
int ans = sum_of_digits(n);
printf("%d",ans);
return 0;
}
Which of the following lines should be inserted to complete the above code?Select an option to see the answer and solution.
Q968
Open questionSelect an option to see the answer and solution.
Q969
Open questionSelect an option to see the answer and solution.
Q970
Open question#include<stdio.h>
int get_len(char *s)
{
int len = 0;
while(________)
len++;
return len;
}
int main()
{
char *s = "harsh";
int len = get_len(s);
printf("%d",len);
return 0;
}
Which of the following lines should be inserted to complete the above code?Select an option to see the answer and solution.
Q971
Open questionSelect an option to see the answer and solution.
Q972
Open question#include<stdio.h>
#include<stdlib.h>
struct Node
{
int val;
struct Node* next;
}*head;
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 = 5, arr[5] ={1,1,1,1,1},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 min_num = recursive_get_min(head->next);
printf("%d",min_num);
return 0;
}Select an option to see the answer and solution.
Q973
Open questionSelect an option to see the answer and solution.
Q974
Open questionSelect an option to see the answer and solution.
Q975
Open questionSelect an option to see the answer and solution.
Q976
Open questionSelect an option to see the answer and solution.
Q977
Open questionSelect an option to see the answer and solution.
Q978
Open questionSelect an option to see the answer and solution.
Q979
Open questionSelect an option to see the answer and solution.
Q980
Open questionSelect an option to see the answer and solution.