C-MCQs set-2


Q1. What is the output of the following code snippet ?

 
    main()
{
    int const a = 5;
    a++;
    printf(“%d”,a);
}

Options:
a) 5 b) 6 c) Run time error d) Compile time error



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

  
    main()
{
    int i = 1;
    while( i++<=5 )
    printf("%d ",i++);
}


Options:
a) 1 3 5 b) 2 4 c) 2 4 6 d) 2



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


  
    main()
{
    int a[] = {2,1};
    printf("%d", *a);
}



Options
a) 0 b) 1 c) 2 d) Compile error



Q4. Choose the correct option in respect to the following program.

 
    void f(int const i)
{
    i=5;
}
    main()
{
    int x = 10;
    f(x);
}

I - Error in the statement ‘void f(int const i)’

II - Error in the statement i=5.
 
Options
a) Statements I & II are true b) Statements I & II are false c) Statements I is true d) Statements II are true



Q5. What will be the output of the given below code?

  
    int main()
{
    const int *ptr = &i;
    char str[] = "Welcome";
    s = str;
    while(*s)
    printf("%c", *s++);
    return 0;
}



Options
a) Welcome b) o c) Wel d) come



Q6. What is the output of the below code snippet?

 
    main()
{
    int a = 5, b = 3, c = 4;
    printf("a = %d, b = %d\n", a, b, c);
}


Options
a) a=5, b=3 b) a=5, b=3, c=0 c) a=5, b=3, 0 d) compile error



Q7. What will be the output of the following program ?

  
    struct student
{

};
    void main()
{
    struct student s[2];
    printf("%d", sizeof(s));
}



Options
a) 2 b) 4 c) 8 d) 0



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

 
  
    int main()
{
    int c = 2 ^ 3;
    printf("%d\n", c);

}


Options
a) 1 b) 8 c) 9 d) 0



Q9. What will be the output ?

  
  
    void main()
{
    float x = 0.1;
    if (x == 0.1)
      printf("Coding");
    else
      printf("Datacode");
}



Options:
a) Datacode b) Coding c) Run time error d) Compile time error



Q10. What will be the output ?

  
    int main()
{
    int a = 10, b = 5, c = 5;
    int d;
    d = b + c == a;
    printf("%d", d);
}



Options
a) Syntax error b) 1 c) 5 d) 10