Walk In Drive : Bengalore , Hyderabad , Delhi , Chennai , Mumbai , Kolkata ->Books : Let Us C (Yashavant P.Kanetkar) , Quantitative Aptittude(RS Agrawal) , Verbal Reasoning(RS Agrawal) , SQL

C Programming Test 2

8.
Which of the statements is correct about the program?
#include<stdio.h>

int main()
{
    int arr[3][3] = {1, 2, 3, 4};
    printf("%d\n", *(*(*(arr))));
    return 0;
}

A.
Output: Garbage value

B.
Output: 1

C.
Output: 3

D.
Error: Invalid indirection
9.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    char str[] = "Interview\0\Shala\0";
    printf("%s\n", str);
    return 0;
}

A.Shala

B.
Interview

C.Interview Shala

D.
Interview\0Shala
10.
What will be the output of the program in Turbo C (under DOS)?
#include<stdio.h>

int main()
{
    struct emp
    {
        char *n;
        int age;
    };
    struct emp e1 = {"Dravid", 23};
    struct emp e2 = e1;
    strupr(e2.n);
    printf("%s\n", e1.n);
    return 0;
}

A.
Error: Invalid structure assignment

B.
DRAVID

C.
Dravid

D.
No output
11.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct a
    {
        float category:5;
        char scheme:4;
    };
    printf("size=%d", sizeof(struct a));
    return 0;
}

A.
Error: invalid structure member in printf

B.
Error in this float category:5; statement

C.
No error

D.
None of above
12.
Point out the error in the program?
#include<stdio.h>
#include<string.h>
void modify(struct emp*);
struct emp
{
    char name[20];
    int age;
};
int main()
{
    struct emp e = {"Sanjay", 35};
    modify(&e);
    printf("%s %d", e.name, e.age);
    return 0;
}
void modify(struct emp *p)
{
     p ->age=p->age+2;
}

A.
Error: in structure

B.
Error: in prototype declaration unknown struct emp

C.
No error

D.
None of above
13.
The '.' operator can be used access structure elements using a structure variable.

A.
True

B.
False
14.
Can we specify a variable filed width in a scanf() format string?

A.
Yes

B.
No
15.
Which header file should be included to use functions like malloc() and calloc()?

A.
memory.h

B.
stdlib.h

C.
string.h

D.
dos.h
16.
If malloc() successfully allocates memory it returns the number of bytes it has allocated.

A.
True

B.
False
17.
In a function that receives variable number of arguments the fixed arguments passed to the function can be at the end of argument list.

A.
True

B.
False
18.
We can allocate a 2-Dimensional array dynamically.

A.
True

B.
False
19.
Are the following declarations same?
char far *far *scr;
char far far** scr;

A.
Yes

B.
No
20.
What is the purpose of fflush() function.

A.
flushes all streams and specified streams.

B.
flushes only specified stream.

C.
flushes input/output buffer.

D.  flushes file buffer.

ANSWER
1.  A        2.A        3. B      4. B      5. A    6. D    7.D      8.D    9. B    10. B 
 11.B       12. B    13. A     14. B    15. B  16. B   17.B   18.A   19. B   20.  A




                          

   

No comments:

Post a Comment