Questions 101–106 of 106. Imported answers require independent review unless marked reviewed.

Topic practice 106 questionsPage 11 of 11

Question 38

Open question
CSMCQ2 marksNeeds review
Consider the following C function.
int fun(int n) { int i, j; for(i = 1; i<= n; i++) { for(j = 1; j < n; j += i) { printf("%d %d", i, j); } } }
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 43

Open question
CSNAT2 marksNeeds review
Consider the following snippet of a C program. Assume that swap(&x, &y) exchanges the contents of x and y.
int main() {
int array[] = {3, 5, 1, 4, 6, 2};
int done = 0;
int i;

while (done == 0) {
done = 1;
for (i=0; i<=4; i++) {
if (array[i] < array[i+1]) {
swap(&array[i], &array[i+1]);
done = 0;
}
}
for (i=5; i>=1; i--) {
if (array[i] > array[i-1]) {
swap(&array[i], &array[i-1]);
done = 0;
}
}
}
printf("%d", array[3]);
}
The output of the program is __________.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 53

Open question
CSNAT2 marksNeeds review
Consider the following C program.
#include<stdio.h> #include <string.h>

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 54

Open question
CSNAT2 marksNeeds review
Consider the following C Program.
#include<stdio.h>
int main() {
int m = 10;
int n, n1;
n = ++m;
n1 = m++;
n--;
--n1;
n -= n1;
printf("%d", n);
return 0;
}
The output of the program is __________.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 55

Open question
CSNAT2 marksNeeds review
The output of executing the following C program is ________.
#include<stdio.h>

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

Question 55

Open question
CSNAT2 marksNeeds review
Consider the following C Program.
#include<stdio.h>
#include<string.h>
int main() {
char* c = "GATECSIT2017";
char* p = c;
printf("%d", (int)strlen(c+2[p]-6[p]-1));
return 0;
}
The output of the program is __________.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer