Q921
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
47/59
Page
Pick an option on a question to see the right answer and solution.
Q921
Open questionSelect an option to see the answer and solution.
Q922
Open questionSelect an option to see the answer and solution.
Q923
Open questionSelect an option to see the answer and solution.
Q924
Open questionSelect an option to see the answer and solution.
Q925
Open questionSelect an option to see the answer and solution.
Q926
Open questionint fact(int n)
{
if(_________)
return 1;
return n * fact(n - 1);
}
int main()
{
int n = 5;
int ans = fact(n);
printf("%d",ans);
return 0;
}Select an option to see the answer and solution.
Q927
Open questionSelect an option to see the answer and solution.
Q928
Open questionSelect an option to see the answer and solution.
Q929
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.
Q930
Open questionSelect an option to see the answer and solution.
Q931
Open questionSelect an option to see the answer and solution.
Q932
Open questionSelect an option to see the answer and solution.
Q933
Open questionSelect an option to see the answer and solution.
Q934
Open questionSelect an option to see the answer and solution.
Q935
Open questionSelect an option to see the answer and solution.
Q936
Open question#include <bits/stdc++.h>
using namespace std;
void convert(int a[], int n)
{
vector <pair<int, int> > vec;
for (int i = 0; i < n; i++)
vec.push_back(make_pair(a[i], i));
sort(vec.begin(), vec.end());
for (int i=0; i<n; i++)
a[vec[i].second] = i;
}
void printArr(int a[], int n)
{
for (int i=0; i<n; i++)
cout << a[i] << " ";
}
int main()
{
int arr[] = {10,8,2,5,7};
int n = sizeof(arr)/sizeof(arr[0]);
convert(arr , n);
printArr(arr, n);
return 0;
}Select an option to see the answer and solution.
Q937
Open questionint recursive_binary_search(int *arr, int num, int lo, int hi)
{
if(lo > hi)
return -1;
int mid = (lo + hi)/2;
if(arr[mid] == num)
return mid;
else if(arr[mid] < num)
lo = mid + 1;
else
hi = mid - 1;
return recursive_binary_search(arr, num, lo, hi);
}Select an option to see the answer and solution.
Q938
Open questionSelect an option to see the answer and solution.
Q939
Open questionSelect an option to see the answer and solution.
Q940
Open questionSelect an option to see the answer and solution.