Interesting questions in C
Here are some intersting questions in C. Just for fun questions.
Me being a techie (atleast Id like to think of myself like that) Ill torment people often with such stuff... :) Kindly bear with me...
1.) You have an integer array of 1000 elements with the ith element obtained by the formula
a[i] = 2*i+3
Which of the following sorting algorithms will sort the array the fastest..
a.) Quick sort b.) Bubble sort c.) Selection sort d.) Heap sort
2.) What will be the output of the following code snippet
int i, j, k;
k = (i/j) * (j/i);
printf ("%d", k);
3.) Predict the output
main() { int x=5, *y; void *z; y=z=&x; y++; z++; printf("\n%u%",y,z); }
4.) In the current format, the following code snippet will run infinitely.
int i;
for (i=0; i<5; i--) printf ("*");
By just adding/deleintg/modifying a single character in the second line of the above code snippet make the code print exactly five *'s
5.) Write a program in C to print the string "Hello World". The constraint is that there should not be any semi-colons in the code.
6.) What is mutual recursion?
7.) What is the output of the following program?
void function(int a, int b, int c)
{
char buffer1[5];
char buffer2[10];
int *ret;
ret = buffer1 + 12;
(*ret) += 8;
}
void main()
{
int x;
x = 0;
function(1,2,3);
x = 1;
printf("%d\n",x);
}
8.) Most programming languages provide a facility called semaphores to lock resources for exclusive use. Why is this needed? Why cant the application developer have a boolean to control the access of the boolean?
Answers in the next post....
நிரந்தரமானவன் [தே. குமரன்]
4 years ago
No comments:
Post a Comment