C Questions

0 votes, 0 avg
750

C Questions

1 / 15

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

2 / 15

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

        }

3 / 15

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

        #include 

        void main()

        {

            int a[2][3] = {1, 2, 3, , 4, 5};

            int i = 0, j = 0;

            for (i = 0; i < 2; i++)

            for (j = 0; j < 3; j++)

            printf("%d", a[i][j]);

        }

4 / 15

4. What is storage class for variable A in below code?


int main()
{
int A;
A = 10;
printf("%d", A);
return 0;
}

5 / 15

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

#include 
void solve() {
    int x = 1, y = 2;
    printf(x > y ? "Greater" : x == y ? "Equal" : "Lesser");
}
int main() {
    solve();
return 0;
} 

6 / 15

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

        #include 

        int main()

        {

            int a = 1, b = 2, c = 3;

            int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;

            int **sptr = &ptr1; //-Ref

            *sptr = ptr2;

        }

7 / 15

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

8 / 15

8. The parameter control string in the printf () is a C String that contains text to be __________

9 / 15

9. Which of the following format specifiers is used to specify whether the given time is in AM or PM?

10 / 15

10. Which of the following is a correct format for declaration of function?

11 / 15

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

12 / 15

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

#include 

int main(){
    int i, j;

    for (i = 2; i < 10; i++) {
        for (j = 2; j <= (i / j); j++)
            if (!(i % j))
                break;
        if (j > (i / j))
            printf("%d ", i);
    }

    return 0;
}

13 / 15

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

#include 
void solve() {
    int a = 3;
    int res = a++ + ++a + a++ + ++a;
    printf("%d", res);
}
int main() {
solve();
return 0;
}

14 / 15

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

15 / 15

15. What is the default return type if it is not specified in function definition?

Your score is

The average score is 38%

0%

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

Scroll to Top