C Program find Output code snippet SET - 3


1.
Which of the following cannot be checked in a switch-case statement?
A.
Character
B.
Integer
C.
Float
D.
enum
Workspace

2.
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
    int a = 10, b;
    a >=5 ? b=100: b=200;
    printf("%d\n", b);
    return 0;
}
A.
100
B.
200
C.
Error: L value required for b
D.
Garbage value
Workspace

3.
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
    int x = 30, y = 40;
    if(x == y)
        printf("x is equal to y\n");

    else if(x > y)
        printf("x is greater than y\n");

    else if(x < y)
        printf("x is less than y\n")
    return 0;
}
A.
Error: Statement missing
B.
Error: Expression syntax
C.
Error: Lvalue required
D.
Error: Rvalue required
Workspace

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

5.
Are the following two statement same?
1.
a <= 20 ? (b = 30): (c = 30);
2.
(a <=20) ? b : (c = 30);
A.
Yes
B.
No
Workspace

6.
Macros have a local scope.
A.
True
B.
False
Workspace

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

int main()
{
    char *str;
    str = "%d\n";
    str++;
    str++;
    printf(str-2, 300);
    return 0;
}
A.
No output
B.
30
C.
3
D.
300
Workspace

8.
Is this a correct way for NULL pointer assignment?
int i=0;
char *q=(char*)i;
A.
Yes
B.
No
Workspace

9.
What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?
#include<stdio.h>

int main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
    printf("%u, %u\n", a+1, &a+1);
    return 0;
}
A.
65474, 65476
B.
65480, 65496
C.
65480, 65488
D.
65474, 65488
Workspace

10.
The library function used to reverse a string is
A.
strstr()
B.
strrev()
C.
revstr()
D.
strreverse()
Workspace

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

int main()
{
    char sentence[80];
    int i;
    printf("Enter a line of text\n");
    gets(sentence);
    for(i=strlen(sentence)-1; i >=0; i--)
        putchar(sentence[i]);
    return 0;
}
A.
The sentence will get printed in same order as it entered
B.
The sentence will get printed in reverse order
C.
Half of the sentence will get printed
D.
None of above
Workspace

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

    struct course
    {
        int courseno;
        char coursename[25];
    };
int main()
{
    struct course c[] = { {102, "Java"},
                          {103, "PHP"},
                          {104, "DotNet"}     };

    printf("%d ", c[1].courseno);
    printf("%s\n", (*(c+2)).coursename);
    return 0;
}
A.
103 DotNet
B.
102 Java
C.
103 PHP
D.
104 DotNet
Workspace

13.
Point out the error in the program?
struct emp
{
    int ecode;
    struct emp *e;
};
A.
Error: in structure declaration
B.
Linker Error
C.
No Error
D.
None of above
Workspace

14.
On declaring a structure 0 bytes are reserved in memory.
A.
True
B.
False
Workspace

15.
On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?
#include<stdio.h>

int main()
{
    int i, fss;
    char ch, source[20] = "source.txt", target[20]="target.txt", t;
    FILE *fs, *ft;
    fs = fopen(source, "r");
    ft = fopen(target, "w");
    while(1)
    {
        ch=getc(fs);
        if(ch==EOF)
            break;
        else
        {
            fseek(fs, 4L, SEEK_CUR);
            fputc(ch, ft);
        }
    }
    return 0;
}
A.
r n
B.
Trh
C.
err
D.
None of above
Workspace

16.
What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)?
cmd> sample 1 2 3
/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    int j;
    j = argv[1] + argv[2] + argv[3];
    printf("%d", j);
    return 0;
}
A.
6
B.
sample 6
C.
Error
D.
Garbage value
Workspace

17.
In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision?
A.
Yes
B.
No
Workspace

18.
Bitwise | can be used to multiply a number by powers of 2.
A.
Yes
B.
No
Workspace

19.
What do the following declaration signify?
int *f();
A.
f is a pointer variable of function type.
B.
f is a function returning pointer to an int.
C.
f is a function pointer.
D.
f is a simple declaration of pointer variable.
Workspace

20.
What will be the output of the program under DOS?
#include<stdio.h>

int main()
{
    char huge *near *far *ptr1;
    char near *far *huge *ptr2;
    char far *huge *near *ptr3;
    printf("%d, %d, %d\n", sizeof(ptr1), sizeof(**ptr2), sizeof(ptr3));
    return 0;
}
A.
4, 4, 4
B.
4, 2, 2
C.
2, 8, 4
D.
2, 4, 8


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