Q1061
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
54/59
Page
Pick an option on a question to see the right answer and solution.
Q1061
Open questionSelect an option to see the answer and solution.
Q1062
Open question#include<iostream>
using namespace std;
void printArray(int p[], int n)
{
for (int i = 0; i <= n-1; i++)
cout << p[i] << " ";
cout << endl;
}
void func1(int n)
{
int p[n];
int k = 0;
p[k] = n;
while (true)
{
printArray(p, k+1);
int rem_val = 0;
while (k >= 0 && p[k] == 1)
{
rem_val += p[k];
k--;
}
if (k < 0) return;
p[k]--;
rem_val++;
while (rem_val > p[k])
{
p[k+1] = p[k];
rem_val = rem_val - p[k];
k++;
}
p[k+1] = rem_val;
k++;
}
}
int main()
{
int n;
cin>>n;
func1(n);
return 0;
}Select an option to see the answer and solution.
Q1063
Open questionvoid Cipher(string msg, string key)
{
// Get key matrix from the key string
int keyMat[3][3];
getKeyMatrix(key, keyMat);
int msgVector[3][1];
for (int i = 0; i <=2; i++)
msgVector[i][0] = (msg[i]) % 65;
int cipherMat[3][1];
// Following function generates
// the encrypted vector
encrypt(cipherMat, keyMat, msgVector);
string CipherText;
for (int i = 0; i <=2; i++)
CipherText += cipherMat[i][0] + 65;
cout << CipherText;
}Select an option to see the answer and solution.
Q1064
Open questionSelect an option to see the answer and solution.
Q1065
Open questionSelect an option to see the answer and solution.
Q1066
Open questionSelect an option to see the answer and solution.
Q1067
Open questionSelect an option to see the answer and solution.
Q1068
Open questionSelect an option to see the answer and solution.
Q1069
Open questionSelect an option to see the answer and solution.
Q1070
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;
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] = {1,1,1,0,-1,-1,-1};
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.
Q1071
Open questionSelect an option to see the answer and solution.
Q1072
Open questionSelect an option to see the answer and solution.
Q1073
Open questionSelect an option to see the answer and solution.
Q1074
Open questionint fact(int n)
{
if(n == 0)
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.
Q1075
Open questionSelect an option to see the answer and solution.
Q1076
Open question#include <bits/stdc++.h>
using namespace std;
void crossP(int A[], int B[], int cross[])
{
cross[0] = A[1] * B[2] - A[2] * B[1];
cross[1] = A[0] * B[2] - A[2] * B[0];
cross[2] = A[0] * B[1] - A[1] * B[0];
}
int main()
{
int A[] = { 1, 2, 4 };
int B[] = { 2, 3, 2 };
int cross[3];
crossP(A, B, cross);
for (int i = 0; i < 3; i++)
cout << cross[i] << " ";
return 0;
}Select an option to see the answer and solution.
Q1077
Open questionSelect an option to see the answer and solution.
Q1078
Open questionSelect an option to see the answer and solution.
Q1079
Open questionSelect an option to see the answer and solution.
Q1080
Open questionSelect an option to see the answer and solution.