C Questions

0 votes, 0 avg
234

C Questions

1 / 15

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

#include 

int main()
{
    float x = 21.0;
    x %= 3.0;
    printf("%f",x);

    return 0;
}

2 / 15

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

3 / 15

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

        #include 

        void main()

        {

            double k = 0;

            for (k = 0.0; k < 3.0; k++)

                printf("Hello");

        }

4 / 15

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

5 / 15

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

6 / 15

6. Which of the following is an exit controlled loop?

7 / 15

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

8 / 15

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

#include 
void solve() {
    int first = 10, second = 20;
    int third = first + second;
    {
        int third = second - first;
        printf("%d ", third);
    }
    printf("%d", third);
}
int main() {
solve();
return 0;
}

9 / 15

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

10 / 15

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

        #include 

        int main()

        {

            enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};

            printf("PEACH = %dn", PEACH);

        }

11 / 15

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

12 / 15

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

13 / 15

13. Is initialisation mandatory for local static variables?

14 / 15

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

15 / 15

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

string p = "HELLO";

Your score is

The average score is 30%

0%