C Questions

0 votes, 0 avg
726

C Questions

1 / 15

1. Global variables are ____________

2 / 15

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

#include 

int main()
{
    float x = 21.0;
    x %= 3.0;
    printf("%f",x);

    return 0;
}

3 / 15

3. 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;
}

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. Which option should be selected to work the following C expression?

string p = "HELLO";

6 / 15

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

        }

7 / 15

7. 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");

        }

8 / 15

8. What will be the output of the following code snippet?

#include 
void solve() {
    int a = 3;
    int res = a++ + ++a + a++ + ++a;
    printf("%d", res);
}
int main() {
solve();
return 0;
}

9 / 15

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

10 / 15

10. 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");
    }
}

11 / 15

11. double ______ (double x, double y) computes the floating-point remainder of x/y.

12 / 15

12. What type of array is generally generated in Command-line argument?

13 / 15

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

        #include 

        int main()

        {

            const int ary[4] = {1, 2, 3, 4};

            int *p;

            p = ary + 3;

            *p = 5;

            printf("%dn", ary[3]);

        }

14 / 15

14. What will be the output of the following C code considering the size of a short int is 2, char is 1 and int is 4 bytes?

        #include 

        int main()

        {

            short int i = 20;

            char c = 97;

            printf("%d, %d, %dn", sizeof(i), sizeof(c), sizeof(c + i));

            return 0;

        }

15 / 15

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

        #include 

        int main()

        {

            int x = 0;

            if (x == 1)

                if (x == 0)

                    printf("inside ifn");

                else

                    printf("inside else ifn");

            else

                printf("inside elsen");

        }

Your score is

The average score is 38%

0%