C Questions

0 votes, 0 avg
641

C Questions

1 / 15

1. Which option should be selected to work the following C expression?

string p = "HELLO";

2 / 15

2. How are String represented in memory in C?

3 / 15

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

4 / 15

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

#include 

union values {
    int val1;
    char val2;
} myVal;

int main()
{
    myVal.val1 = 66;
    
    printf("val1 = %p", &myVal.val1);
    printf("nval2 = %p", &myVal.val2);
    
    return 0;
}

5 / 15

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

6 / 15

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

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

7 / 15

7. If p is an integer pointer with a value 1000, then what will the value of p + 5 be?

8 / 15

8. Size of an array can be evaluated by __________

(Assuming array declaration int a[10];)

9 / 15

9. What is an example of iteration in C?

10 / 15

10. What is the use of symbol * in the control string as shown [=%[*][width] [modifiers] type=]?

11 / 15

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

12 / 15

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

}


                            

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 

int main()
{
    char str1[] = { 'H', 'e', 'l', 'l', 'o' };
    char str2[] = "Hello";

    printf("%ld,%ld", sizeof(str1), sizeof(str2));

    return 0;
}

15 / 15

15. What does the following program print?

#include
void f(int *p, int *q)
{
  p = q;
 *p = 2;
}
int i = 0, j = 1;
int main()
{
  f(&i, &j);
  printf("%d %d n", i, j);
  getchar();
  return 0;
}

Your score is

The average score is 39%

0%