C Program find Output code snippet SET - 8





1.
Which statement will you add in the following program to work it correctly?
#include<stdio.h>
int main()
{
    printf("%f\n", log(36.0));
    return 0;
}
A.
#include<conio.h>
B.
#include<math.h>
C.
#include<stdlib.h>
D.
#include<dos.h>
Workspace

2.
What will be the output of the program?
#include<stdio.h>
#define PRINT(i) printf("%d,",i)

int main()
{
    int x=2, y=3, z=4;
    PRINT(x);
    PRINT(y);
    PRINT(z);
    return 0;
}
A.
2, 3, 4,
B.
2, 2, 2,
C.
3, 3, 3,
D.
4, 4, 4,
Workspace

3.
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?
#include<stdio.h>

int main()
{
    int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
    return 0;
}
A.
448, 4, 4
B.
520, 2, 2
C.
1006, 2, 2
D.
Error
Workspace

4.
Which of the following statements correct about k used in the below statement?
char ****k;
A.
k is a pointer to a pointer to a pointer to a char
B.
k is a pointer to a pointer to a pointer to a pointer to a char
C.
k is a pointer to a char pointer
D.
k is a pointer to a pointer to a char
Workspace

5.
What does the following declaration mean?
int (*ptr)[10];
A.
ptr is array of pointers to 10 integers
B.
ptr is a pointer to an array of 10 integers
C.
ptr is an array of 10 integers
D.
ptr is an pointer to array
Workspace

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

int main()
{
    int arr[5], i=-1, z;
    while(i<5)
        arr[i]=++i;

    for(i=0; i<5; i++)
        printf("%d, ", arr[i]);

    return 0;
}
A.
1, 2, 3, 4, 5,
B.
-1, 0, 1, 2, 3, 4
C.
0, 1, 2, 3, 4,
D.
0, -1, -2, -3, -4,
Workspace

7.
What will be the output of the program in 16-bit platform (Turbo C under DOS) ?
#include<stdio.h>

int main()
{
    printf("%d, %d, %d", sizeof(3.0f), sizeof('3'), sizeof(3.0));
    return 0;
}
A.
8, 1, 4
B.
4, 2, 8
C.
4, 2, 4
D.
10, 3, 4
Workspace

8.
Point out the error in the program?
#include<stdio.h>

int main()
{
    struct emp
    {
        char name[20];
        float sal;
    };
    struct emp e[10];
    int i;
    for(i=0; i<=9; i++)
        scanf("%s %f", e[i].name, &e[i].sal);
    return 0;
}
A.
Error: invalid structure member
B.
Error: Floating point formats not linked
C.
No error
D.
None of above
Workspace

9.
A structure can contain similar or dissimilar elements
A.
True
B.
False
Workspace

10.
A pointer union CANNOT be created
A.
Yes
B.
No
Workspace

11.
What will be the output of the program if value 25 given to scanf()?
#include<stdio.h>

int main()
{
    int i;
    printf("%d\n", scanf("%d", &i));
    return 0;
}
A.
25
B.
2
C.
1
D.
5
Workspace

12.
Point out the error in the program?
#include<stdio.h>
#include<stdlib.h>

int main()
{
    unsigned char;
    FILE *fp;
    fp=fopen("trial", "r");
    if(!fp)
    {
        printf("Unable to open file");
        exit(1);
    }
    fclose(fp);
    return 0;
}
A.
Error: in unsigned char statement
B.
Error: unknown file pointer
C.
No error
D.
None of above
Workspace

13.
What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)?
cmd> sample Good Morning
/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%d %s", argc, argv[1]);
    return 0;
}
A.
3 Good
B.
2 Good
C.
Good Morning
D.
3 Morning
Workspace

14.
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample friday tuesday sunday
/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])
{
    printf("%c", *++argv[2] );
    return 0;
}
A.
s
B.
f
C.
u
D.
r
Workspace

15.
Even if integer/float arguments are supplied at command prompt they are treated as strings.
A.
True
B.
False
Workspace

16.
If the different command line arguments are supplied at different times would the output of the following program change?
#include<stdio.h>

int main(int argc, char **argv)
{
    printf("%d\n", argv[argc]);
    return 0;
}
A.
Yes
B.
No
Workspace

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

typedef struct error {int warning, err, exception;} ERROR;
int main()
{
    ERROR e;
    e.err=1;
    printf("%d\n", e.err);
    return 0;
}
A.
0
B.
1
C.
2
D.
Error
Workspace

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

int main()
{
    const int i=0;
    printf("%d\n", i++);
    return 0;
}
A.
10
B.
11
C.
No output
D.
Error: ++needs a value
Workspace

19.
Which standard library function will you use to find the last occurance of a character in a string in C?
A.
strnchar()
B.
strchar()
C.
strrchar()
D.
strrchr()
Workspace

20.
Data written into a file using fwrite() can be read back using fscanf()
A.
True
B.
False

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