C Questions

0 votes, 0 avg
134

C Questions

1 / 15

1. Global variables are ____________

2 / 15

2. Comment on the output of the following C code.

        #include 

        struct temp

        {

            int a;

            int b;

            int c;

        };

        main()

        {

            struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

        }

3 / 15

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

        #include 

        void main()

        {

            double k = 0;

            for (k = 0.0; k < 3.0; k++)

                printf("Hello");

        }

4 / 15

4. 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]);

        }

5 / 15

5. What will fopen will return, if there is any error while opening a file?

6 / 15

6. What is #include < stdio.h > ?

7 / 15

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

        #include 

        #include 

        void main()

        {

            int k = pow(2, 3);

            printf("%dn", k);

        }

8 / 15

8. What will happen if a header file is included in a program twice?

9 / 15

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

#include 

int main(){
    char grade = 'B';

    switch (grade) {
    case 'A':
        printf("Excellent!n");
    case 'B':
    case 'C':
        printf("Well donen");
    case 'D':
        printf("You passedn");
    case 'F':
        printf("Better try againn");
        break;
    default:
        printf("Invalid graden");
    }
}

10 / 15

10. Which of the following is not a valid C variable name?

11 / 15

11. Why do variable names beginning with the underscore is not encouraged?

12 / 15

12. Libray function getch() belongs to which header file?

13 / 15

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

14 / 15

14. Multiple values of the same variable can be tested using ___.

15 / 15

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

        #include 

        void foo(int *ary[]);

        int main()

        {

            int ary[2][3];

            foo(ary);

        }

        void foo(int *ary[])

        {

            int i = 10, j = 2, k;

            ary[0] = &i;

            ary[1] = &j;

            *ary[0] = 2;

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

            printf("%dn", *ary[k]);

        }

Your score is

The average score is 30%

0%