C Questions

0 votes, 0 avg
728

C Questions

1 / 15

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

2 / 15

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

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 

        struct student

        {

            char *c;

            struct student *point;

        };

        void main()

        {

            struct student s;

            printf("%d", sizeof(s));

        }

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. Which of the following is not a storage class specifier in C?

7 / 15

7. Array sizes are optional during array declaration by using ______ keyword.

8 / 15

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

#include 
int main() {
	int a = 3, b = 5;
	int t = a;
	a = b;
	b = t;
	printf("%d %d", a, b);
	return 0;
}

9 / 15

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

10 / 15

10. Comment on the output of the following C code.

        #include 

        struct temp

        {

            int a;

            int b;

            int c;

        };

        main()

        {

            struct temp p[] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

        }

11 / 15

11. What is #include < stdio.h > ?

12 / 15

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

13 / 15

13. 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

14 / 15

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

        }

15 / 15

15. What will fopen will return, if there is any error while opening a file?

Your score is

The average score is 38%

0%

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