C Questions

0 votes, 0 avg
581

C Questions

1 / 15

1. The following function computes the maximum value contained in an integer array p[] of size n (n >= 1) 

int max(int *p, int n)
{
    int a=0, b=n-1;
    while (__________)
    {
        if (p[a] <= p[b])
        {
            a = a+1;
        }
        else
        {
            b = b-1;
        }
    }
    return p[a];
}

The missing loop condition is

2 / 15

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

        }

3 / 15

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

4 / 15

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

        }

5 / 15

5. Size of an array can be evaluated by __________

(Assuming array declaration int a[10];)

6 / 15

6. Which C keyword is used to extend the visibility of variables?

7 / 15

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

8 / 15

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

9 / 15

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

10 / 15

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

11 / 15

11. Which of the following is true for the static variable?

12 / 15

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

#include 

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

13 / 15

13. In C, parameters are always 

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. Which of the following are themselves a collection of different data types?

Your score is

The average score is 40%

0%