C Questions

0 votes, 0 avg
43

C Questions

1 / 15

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

        #include 

        #include 

        void main()

        {

            int k = pow(2, 3);

            printf("%dn", k);

        }

2 / 15

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

3 / 15

3. Size of an array can be evaluated by __________

(Assuming array declaration int a[10];)

4 / 15

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

#include 
int main() {
	int a = 3, b = 5;
	int t = a;
	a = b;
	b = t;
	printf("%d %d", a, b);
	return 0;
}

5 / 15

5. Which of the following is the correct syntax to declare a 3 dimensional array using pointers?

6 / 15

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

        }

7 / 15

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

#include 

int main(){
    int i, j;

    for (i = 2; i < 10; i++) {
        for (j = 2; j <= (i / j); j++)
            if (!(i % j))
                break;
        if (j > (i / j))
            printf("%d ", i);
    }

    return 0;
}

8 / 15

8. The standard header _______ is used for variable list arguments (…) in C.

9 / 15

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

10 / 15

10. The syntax of the scanf() is scanf(“control string “, arg1,arg2,arg3,….,argn); the prototype of control string is ____________

11 / 15

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

    #include 

    void main()

    {

        int i = 0;

        while (i < 10)

        {

            i++;

            printf("hin");

            while (i < 8) 

            {

                i++;

                printf("hellon");

            }

        }

    }

12 / 15

12. Which of the following is not a storage class specifier in C?

13 / 15

13. 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;

        }

14 / 15

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

#include 

int main(){
    int a = 11;
    
    while (a < 20) {
        printf("%d  ", a);
        a += 2;
    }
    
    return 0;
}

15 / 15

15. Which of the following option is the correct representation of the following C statement?

e = a * b + c / d * f;

Your score is

The average score is 28%

0%