C Program find Output code snippet SET - 7


 

1.
How many times "IndiaBIX" is get printed?
#include<stdio.h>
int main()
{
    int x;
    for(x=-1; x<=10; x++)
    {
        if(x < 5)
            continue;
        else
            break;
        printf("IndiaBIX");
    }
    return 0;
}
A.
Infinite times
B.
11 times
C.
0 times
D.
10 times
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.
1, 2, 0, 1
B.
-3, 2, 0, 1
C.
-2, 3, 0, 1
D.
2, 3, 1, 1
Workspace

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

int addmult(int ii, int jj)
{
    int kk, ll;
    kk = ii + jj;
    ll = ii * jj;
    return (kk, ll);
}

int main()
{
    int i=3, j=4, k, l;
    k = addmult(i, j);
    l = addmult(i, j);
    printf("%d, %d\n", k, l);
    return 0;
}
A.
12, 12
B.
7, 7
C.
7, 12
D.
12, 7
Workspace

4.
Will the following program print the message infinite number of times?
#include<stdio.h>
#define INFINITELOOP while(1)

int main()
{
    INFINITELOOP
    printf("IndiaBIX");
    return 0;
}
A.
Yes
B.
No
Workspace

5.
What will be the output of the program ?
#include<stdio.h>
int *check(static int, static int);

int main()
{
    int *c;
    c = check(10, 20);
    printf("%d\n", c);
    return 0;
}
int *check(static int i, static int j)
{
    int *p, *q;
    p = &i;
    q = &j;
    if(i >= 45)
        return (p);
    else
        return (q);
}
A.
10
B.
20
C.
Error: Non portable pointer conversion
D.
Error: cannot use static for function parameters
Workspace

6.
If the size of integer is 4bytes, What will be the output of the program?
#include<stdio.h>

int main()
{
    int arr[] = {12, 13, 14, 15, 16};
    printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
    return 0;
}
A.
10, 2, 4
B.
20, 4, 4
C.
16, 2, 2
D.
20, 2, 2
Workspace

7.
In the following program add a statement in the function fact() such that the factorial gets stored in j.
#include<stdio.h>
void fact(int*);

int main()
{
    int i=5;
    fact(&i);
    printf("%d\n", i);
    return 0;
}
void fact(int *j)
{
    static int s=1;
    if(*j!=0)
    {
        s = s**j;
        *j = *j-1;
        fact(j);
        /* Add a statement here */
    }
}
A.
j=s;
B.
*j=s;
C.
*j=&s;
D.
&j=s;
Workspace

8.
What will be the output of the program if the array begins at address 65486?
#include<stdio.h>

int main()
{
    int arr[] = {12, 14, 15, 23, 45};
    printf("%u, %u\n", arr, &arr);
    return 0;
}
A.
65486, 65488
B.
65486, 65486
C.
65486, 65490
D.
65486, 65487
Workspace

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

int main()
{
    int i;
    char a[] = "\0";
    if(printf("%s", a))
        printf("The string is empty\n");
    else
        printf("The string is not empty\n");
    return 0;
}
A.
The string is empty
B.
The string is not empty
C.
No output
D.
0
Workspace

10.
What will be the output of the following program in 16 bit platform assuming that 1022 is memory address of the string "Hello1" (in Turbo C under DOS) ?
#include<stdio.h>

int main()
{
    printf("%u %s\n", &"Hello1", &"Hello2");
    return 0;
}
A.
1022 Hello2
B.
Hello1 1022
C.
Hello1 Hello2
D.
1022 1022
E.
Error
Workspace

11.
If a char is 1 byte wide, an integer is 2 bytes wide and a long integer is 4 bytes wide then will the following structure always occupy 7 bytes?
struct ex
{
    char ch;
    int i;
    long int a;
};
A.
Yes
B.
No
Workspace

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

int main()
{
    unsigned char ch;
    FILE *fp;
    fp=fopen("trial", "r");
    while((ch = getc(fp))!=EOF)
        printf("%c", ch);
    fclose(fp);
    return 0;
}
A.
Error: in unsigned char declaration
B.
Error: while statement
C.
No error
D.
It prints all characters in file "trial"
Workspace

13.
What will be the output of the program
#include<stdio.h>
void fun(int);

int main(int argc)
{
    printf("%d\n", argc);
    fun(argc);
    return 0;
}
void fun(int i)
{
    if(i!=4)
        main(++i);
}
A.
1 2 3
B.
1 2 3 4
C.
2 3 4
D.
1
Workspace

14.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    unsigned int num;
    int i;
    scanf("%u", &num);
    for(i=0; i<16; i++)
    {
        printf("%d", (num<<i & 1<<15)?1:0);
    }
    return 0;
}
A.
It prints all even bits from num
B.
It prints all odd bits from num
C.
It prints binary equivalent num
D.
Error
Workspace

15.
What will be the output of the program?
#include<stdio.h>
int fun(int **ptr);

int main()
{
    int i=10;
    const int *ptr = &i;
    fun(&ptr);
    return 0;
}
int fun(int **ptr)
{
    int j = 223;
    int *temp = &j;
    printf("Before changing ptr = %5x\n", *ptr);
    const *ptr = temp;
    printf("After changing ptr = %5x\n", *ptr);
    return 0;
}
A.
Address of i
Address of j
B.
10
223
C.
Error: cannot convert parameter 1 from 'const int **' to 'int **'
D.
Garbage value
Workspace

16.
Can I increase the size of dynamically allocated array?
A.
Yes
B.
No
Workspace

17.
It is necessary to call the macro va_end if va_start is called in the function.
A.
Yes
B.
No
Workspace

18.
What do the following declaration signify?
void (*cmp)();
A.
cmp is a pointer to an void function type.
B.
cmp is a void type pointer function.
C.
cmp is a function that return a void pointer.
D.
cmp is a pointer to a function which returns void .
Workspace

19.
What will be the output of the program (in Turbo C 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, 8
B.
2, 4, 4
C.
4, 4, 2
D.
2, 4, 8
Workspace

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

int main()
{
    char *i = "55.555";
    int result1 = 10;
    float result2 = 11.111;
    result1 = result1+atoi(i);
    result2 = result2+atof(i);
    printf("%d, %f", result1, result2);
    return 0;
}
A.
55, 55.555
B.
66, 66.666600
C.
65, 66.666000
D.
55, 55


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