What is the output of the following C code?
What will be the output of the following C++ code?
Which type of loop can be implemented using the do statement?
#include<stdio.h>
int main()
{
int h=8;
int b=(h++,++h);
printf("%d %d\n",b,h);
return 0;
}
If you specify more arguments than the format specifiers in a printf() statement, what will happen?
What happens when both of the following C++ programs are compiled and executed?
Consider the following C program:
#include <stdio.h> int counter = 0; int calc(int a, int b) { int c; counter++; if (b == 3) return (a * a * a); else { c = calc(a, b / 3); return (c * c * c); } } int main() { calc(4, 81); printf("%d", counter); }
The output of this program is
Consider the C program fragment below which is meant to divide x by y using repeated subtractions. The variable x, y, q and r are all unsigned int.
while(r >= y) { r = r - y; q = q + 1; }
Which of the following conditions on the variables x, y, q and r before the execution of the fragment will ensure that the loop terminates in a state satisfying the condition x == (y*q + r)?
Consider the following two C code segments. Y and X are one and two dimensional arrays of size n and n × n respectively, where 2 ≤ n ≤ 10. Assume that in both code segments, elements of Y are initialized to 0 and each element X[i][j] of array X is initialized to i + j. Further assume that when stored in main memory all elements of X are in same main memory page frame.
Code segment 1: // initialize elements of Y to 0 // initialize elements X[i][j] of X to i+j for (i = 0; i < n; i++) y[i] + = X[0][i]; Code segment 2: // initialize elements of Y to 0 // initialize elements X[i][j] of X to i+j for (i = 0; i < n; i++) y[i] + = X[i][0];
Which of the following statements is/are correct?
S1: Final contents of array Y will be same in both code segments. S2: Elements of array X accessed inside the for loop shown in code segment 1 are contiguous in main memory. S3: Elements of array X accessed inside the for loop shown in code segment 2 are contiguous in main memory.
OnSite
1 Openings
FullTime
Posted 17 days ago