C Questions

0 votes, 0 avg
720

C Questions

1 / 15

1. What is the return type of the fopen() function in C?

2 / 15

2. What will be the output of the following C code?

        #include 

        int *m();

        void main()

        {

            int *k = m();

            printf("hello ");

            printf("%d", k[0]);

        }

        int *m()

        {

            int a[2] = {5, 8};

            return a;

        }

3 / 15

3. Which option should be selected to work the following C expression?

string p = "HELLO";

4 / 15

4. What will be the output of the following C program?

#include 

int main()
{
    int x[5] = { 10, 20, 30 };
    printf("%ld", sizeof(x)/sizeof(x[0]));
    return 0;
}

5 / 15

5. What will be the output of the following C code?

       #include 
        int main()
        {
            int i = 0;
            do
            {
               i++;
                if (i == 2)
                    continue;
                    printf("In while loop ");
            } while (i < 2);
            printf("%dn", i);

        }

6 / 15

6. What will be the output of the following C code?

        #include 

        void main()

        {

            int x = 1, y = 0, z = 5;

            int a = x && y && z++;

            printf("%d", z);

        }

7 / 15

7. What will be the output of the following C code?

        #include 

        int main()

        {

            int a = 1, b = 2, c = 3;

            int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;

            int **sptr = &ptr1; //-Ref

            *sptr = ptr2;

        }

8 / 15

8. What is the output of C Program.?

int main()
{
    int a=0, b=0;
    while(++a < 4)
        printf("%d ", a);

    while(b++ < 4)
        printf("%d ", b);

    return 0;
}

9 / 15

9. What will be the output of the following C code?

        #include 

        struct student

        {

            int no = 5;

            char name[20];

        };

        void main()

        {

            struct student s;

            s.no = 8;

            printf("hello");

        }

10 / 15

10. Size of an array can be evaluated by __________

(Assuming array declaration int a[10];)

11 / 15

11. What will be the final values of i and j in the following C code?

    #include 

int x = 0;

int f()

{

if (x == 0)

return x + 1;

else

return x - 1;

}

int g()

{

return x++;

}

int main()

{

int i = (f() + g()) | g(); //bitwise or

int j = g() | (f() + g()); //bitwise or

}


                            

12 / 15

12. If p is an integer pointer with a value 1000, then what will the value of p + 5 be?

13 / 15

13. What will be the output of the following C code?

        #include 

        void main()

        {

            int a[2][3] = {1, 2, 3, 4, 5};

            int i = 0, j = 0;

            for (i = 0; i < 2; i++)

            for (j = 0; j < 3; j++)

            printf("%d", a[i][j]);

        }

14 / 15

14. scanf() is a predefined function in______header file.

15 / 15

15. What will be the output of the following C program?

#include 

union values {
    int val1;
    char val2;
} myVal;

int main()
{
    myVal.val1 = 66;
    
    printf("val1 = %p", &myVal.val1);
    printf("nval2 = %p", &myVal.val2);
    
    return 0;
}

Your score is

The average score is 39%

0%