C Questions

0 votes, 0 avg
729

C Questions

1 / 15

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

2 / 15

2. What is the output of the following code snippet?

#include 
int main() {
	int a[] = {1, 2, 3, 4};
	int sum = 0;
	for(int i = 0; i < 4; i++) {
	    sum += a[i];
	}
	printf("%d", sum);
	return 0;
}

3 / 15

3. How many times i value is checked in the following C program?

        #include 

        int main()

        {

            int i = 0;

            while (i < 3)

                i++;

            printf("In while loopn");

        }

4 / 15

4. What is the disadvantage of arrays in C?

5 / 15

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

        }

6 / 15

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

#include 

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

7 / 15

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

       }

8 / 15

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

        }

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 final values of i and j in the following C code?

    #include 

int x = 0;

int f()

{

if (x == 0)

return x + 1;

else

return x - 1;

}

int g()

{

return x++;

}

int main()

{

int i = (f() + g()) | g(); //bitwise or

int j = g() | (f() + g()); //bitwise or

}


                            

11 / 15

11. Which of the following is true about return type of functions in C?

12 / 15

12. The concept of two functions with same name is know as?

13 / 15

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

14 / 15

14. What is the return type of the fopen() function in C?

15 / 15

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

Your score is

The average score is 38%

0%

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