SDF-I QUIZ
30.11.2017
Max. Marks: 15 Max. Time: 30Min
1. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending
order using Bubble Sort is
A. 6
B. 5
C. 7
D. 8
2. What are the values of x and y ?
x = 5; y = ++x;
A. x = 6; y = 6
B. x = 5; y = 5
C. x = 6; y = 5
D. x = 5; y = 6
3. What are the values of x and z?
x = 5; z = x++;
A. x = 6; z = 6
B. x = 5; z = 5
C. x = 6; z= 5
D. x = 5; z = 6
4. Choose the correct order of evaluation,
A - Relational Arithmetic Logical Assignment
B - Arithmetic Relational Logical Assignment
C - Logical Arithmetic Relational Assignment
D - Assignment Arithmetic Logical Relational
5. What is the output of the following statement?
#include<stdio.h>
main()
{
printf("\\ri\\ng \\the \\bells");
}
A - \ri\ng \the \bells
B – i g heells
C - i
he \bells
D - None of the above
6. Which library functions help users to dynamically allocate memory?
A - memalloc()and alloc()
B - malloc() and memalloc()
C - malloc() and calloc()
D - memalloc() and calloc()
7. #include<stdio.h>
main()
{
int i = 1;
while(i++<=5);
printf("%d ",i++);
}
A - 4
B - 6
C - 2 6
D - 2 4
8. What is the output of the following program?
#include<stdio.h>
main()
{
int a[] = {2,1};
printf("%d", *a);
}
A - 0
B - 1
C - 2
D - Compile error.
9. What is the output of the following program?
#include<stdio.h>
int x = 5;
int* f()
{
return &x;
}
main()
{
*f() = 10;
printf("%d", x);
}
A - Compile error
B - Runtime error
C - 5
D - 10
10. What is the output of the following program?
#include<stdio.h>
main()
{
struct student
{
int num = 10;
}var;
printf("%d", var.num);
}
A - 10
B - Garbage
C - Runtime error
D - Compile error
11. In the given below statement, what does the “pf” indicate?
int (*pf)();
A - pf is a pointer of a function which return int
B - pf is a pointer
C - pf is a function pointer
D - None of the above
12. What is the size of the following union definition?
#include<stdio.h>
union abc {
char a,b,c,d,e,f,g,h;
int i;
}abc;
main()
{
printf( "%d", sizeof( abc ));
}
A - 1
B - 2
C - 4
D - 8
13. What is the output of the following program?
#include<stdio.h>
main()
{
#undef NULL
char *s = "Hello";
while(*s != NULL)
{
printf("%c", *s++);
}
}
A - Hello
B - Compile error: there is no macro called “undef”
C - Compile error: improper place of #undef
D - Compile error: NULL is undeclared.
14. Choose the correct function which can return a reminder by dividing -
10.0/3.0?
A - rem = mod(-10.0, 3.0);
B - rem = fmod(-10.0, 3.0);
C - rem = modf(-10.0, 3.0);
D - Division of floating point values can’t return reminder
15. If, the given below code finds the length of the string then what
will be the length?
#include<stdio.h>
int xstrlen(char *s)
{
int length = 0;
while(*s!='\0')
{length++; s++;}
return (length);
}
int main()
{
char d[] = "IndiaMAX";
printf("Length = %d\n", xstrlen(d));
return 0;
}
A - Code returns error
B - Code returns the length 8
C - Code returns the length 6
D - Code returns the length 2