C Questions

0 votes, 0 avg
742

C Questions

1 / 15

1. What is the output of C Program.?

int main()
{
    int a=14;
    
    while(a<20)
    {
        ++a;
        if(a>=16 && a<=18)
        {
            continue;
        }
        printf("%d ", a);
       
    }

    return 0;
}

2 / 15

2. In C, parameters are always 

3 / 15

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

4 / 15

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

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 

        struct p

        {

            int k;

            char c;

            float f;

        };

        int p = 10;

        int main()

        {

            struct p x = {1, 97};

            printf("%f %dn", x.f, p);

        }

7 / 15

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

8 / 15

8. What is the output of C Program.?

int main()
{
    int a=10,b=20;
    
    if(a==9 AND b==20)
    {
        printf("Hurray..");
    }
    
    if(a==10 OR b==21)
    {
        printf("Theatre");
    }

    return 0;
}

9 / 15

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

10 / 15

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

        }

11 / 15

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

        }

12 / 15

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

#include 
void solve() {
    int ch = 2;
    switch(ch) {
        case 1: printf("1 ");
        case 2: printf("2 ");
        case 3: printf("3 ");
        default: printf("None");
    }
}
int main() {
    solve();
return 0;
}

13 / 15

13. How are String represented in memory in C?

14 / 15

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

15 / 15

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

        #include 

        struct student

        {

            char *name;

        };

        struct student s[2];

        void main()

        {

            s[0].name = "alan";

            s[1] = s[0];

            printf("%s%s", s[0].name, s[1].name);

            s[1].name = "turing";

            printf("%s%s", s[0].name, s[1].name);

        }

Your score is

The average score is 38%

0%

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top