C Questions

0 votes, 0 avg
721

C Questions

1 / 15

1. The parameter control string in the printf () is a C String that contains text to be __________

2 / 15

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

#include 
void solve() {
    int first = 10, second = 20;
    int third = first + second;
    {
        int third = second - first;
        printf("%d ", third);
    }
    printf("%d", third);
}
int main() {
solve();
return 0;
}

3 / 15

3. How are String represented in memory in C?

4 / 15

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

            }

        }

    }

5 / 15

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

        #include 

        void main()

        {

            char *s = "hello";

            char *p = s * 3;

            printf("%ct%c", *p, s[1]);

        }

6 / 15

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

7 / 15

7. Which of the following is an exit controlled loop?

8 / 15

8. In C, parameters are always 

9 / 15

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

#include 

int main()
{
    float x = 23.456;
    printf("%.2f",x);
    return 0;
}

10 / 15

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

        }

11 / 15

11. Which is correct with respect to the size of the data types?

12 / 15

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

        }

13 / 15

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

#include 

int main()
{
    char str1[] = { 'H', 'e', 'l', 'l', 'o' };
    char str2[] = "Hello";

    printf("%ld,%ld", sizeof(str1), sizeof(str2));

    return 0;
}

14 / 15

14. What is the default return type if it is not specified in function definition?

15 / 15

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

Your score is

The average score is 39%

0%