C Program find Output code snippet SET - 6


1.
The modulus operator cannot be used with a long double.
A.
True
B.
False
Workspace

2.
What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=-3, j=2, k=0, m;
    m = ++i && ++j && ++k;
    printf("%d, %d, %d, %d\n", i, j, k, m);
    return 0;
}
A.
-2, 3, 1, 1
B.
2, 3, 1, 2
C.
1, 2, 3, 1
D.
3, 3, 1, 2
Workspace

3.
In a function two return statements should never occur.
A.
Yes
B.
No
Workspace

4.
It is necessary that a header files should have a .h extension?
A.
Yes
B.
No
Workspace

5.
How many bytes are occupied by near, far and huge pointers (DOS)?
A.
near=2 far=4 huge=4
B.
near=4 far=8 huge=8
C.
near=2 far=4 huge=8
D.
near=4 far=4 huge=8
Workspace

6.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int x=30, *y, *z;
    y=&x; /* Assume address of x is 500 and integer is 4 byte size */
    z=y;
    *y++=*z++;
    x++;
    printf("x=%d, y=%d, z=%d\n", x, y, z);
    return 0;
}
A.
x=31, y=502, z=502
B.
x=31, y=500, z=500
C.
x=31, y=498, z=498
D.
x=31, y=504, z=504
Workspace

7.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    void *vp;
    char ch=74, *cp="JACK";
    int j=65;
    vp=&ch;
    printf("%c", *(char*)vp);
    vp=&j;
    printf("%c", *(int*)vp);
    vp=cp;
    printf("%s", (char*)vp+2);
    return 0;
}
A.
JCK
B.
J65K
C.
JAK
D.
JACK
Workspace

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
Workspace

9.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>

int main()
{
    char str[] = "India\0\BIX\0";
    printf("%s\n", str);
    return 0;
}
A.
BIX
B.
India
C.
India BIX
D.
India\0BIX
Workspace

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
Workspace

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
Workspace

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
Workspace

13.
The '.' operator can be used access structure elements using a structure variable.
A.
True
B.
False
Workspace

14.
Can we specify a variable filed width in a scanf() format string?
A.
Yes
B.
No
Workspace

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
Workspace

16.
If malloc() successfully allocates memory it returns the number of bytes it has allocated.
A.
True
B.
False
Workspace

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
Workspace

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

19.
Are the following declarations same?
char far *far *scr;
char far far** scr;
A.
Yes
B.
No
Workspace

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.


Provide your Output in Comments. We will publish the output soon.

Comments

Popular posts from this blog

Tips 01) self introduction in an interview

Computer Science Terminology

Why Failure Is Good for Success