C Questions

0 votes, 0 avg
726

C Questions

1 / 15

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

        #include 

        int *m();

        void main()

        {

            int *k = m();

            printf("hello ");

            printf("%d", k[0]);

        }

        int *m()

        {

            int a[2] = {5, 8};

            return a;

        }

2 / 15

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

        }

3 / 15

3. What is output of below program?


int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{ 
for(j=0;j<5;j++);
{
    count++;
}
}
printf("%d",count);
return 0;
}

4 / 15

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

        #include 

        int f(char chr, ...);

        int main()

        {

            char c = 97;

            f(c);

            return 0;

        }

        int f(char c, ...)

        {

            printf("%cn", c);

        }

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 

        int main()

        {

            int a = 1, b = 2, c = 3;

            int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;

            int **sptr = &ptr1; //-Ref

            *sptr = ptr2;

        }

7 / 15

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

8 / 15

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

       #include 
        int main()
        {
            int i = 0;
            do
            {
               i++;
                if (i == 2)
                    continue;
                    printf("In while loop ");
            } while (i < 2);
            printf("%dn", i);

        }

9 / 15

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

        }

10 / 15

10. What will be the output of this program?

    int main()      
    {      
    int a=10, b=20;        
    printf("a=%d b=%d",a,b);        
    a=a+b;      
    b=a-b;      
    a=a-b;      
    printf("a=%d b=%d",a,b);      
    return 0;    
    }     

11 / 15

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

12 / 15

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

        #include 

        int main()

        {

            printf("%d ", 1);

            goto l1;

            printf("%d ", 2);

            l1:goto l2;

            printf("%d ", 3);

            l2:printf("%d ", 4);

       }

13 / 15

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

        #include 

        enum birds {SPARROW, PEACOCK, PARROT};

        enum animals {TIGER = 8, LION, RABBIT, ZEBRA};

        int main()

        {

            enum birds m = TIGER;

            int k;

            k = m;

            printf("%dn", k);

            return 0;

        }

14 / 15

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

            }

        }

    }

15 / 15

15. scanf() is a predefined function in______header file.

Your score is

The average score is 38%

0%

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