C-MCQs set-3


Q1. What will be the output ?

 
    int main()
{
    char *s = "TCS Quiz";
    int n = 7;
    printf("%.*s", n, s);
    return 0;
}


Options:
a) TCS Quiz b) nothing is printed c) TCS Q d) TCS Qu



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


    int main()
{
    int i = 1, 2, 3;
    printf("%d", i);
    return 0;
}



Options:
a) 1 b) 3 c) Garbage Value d) Compile time error



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



    int main()
{
    int i = 3;
    printf("%d", (++i)++);
    return 0;
}



Options
a) 3 b) 4 c) 5 d) Compile time error



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


    int main()
{
    int i;
    if (printf("0"))
      i = 3;
    else
      i = 5;
    printf("%d", i);
    return 0;
}



Options
a) 3 b) 5 c) 03 d) 05



Q5. What will be the output ?


    int main()
{ 
    int n;
    for (n = 9; n!=0; n--)
    printf("n = %d", n--);
    return 0;
}



Options
a) 9 7 5 3 1 b) 9 8 7 6 5 4 3 2 1 c) infinite loop d) 9 7 5 3



Q6. Which of the following is the correct order of evaluation for the below expression ?

  
  z = x + y * z / 4 % 2 - 1


Options
a) * / % + - = b) = * / % + - c) / * % - + = d) * % / - + =



Q7. Which of the following is the correct usage of conditional operators used in C?

Options
a) a>b ? c=30 : c=40; b) a>b ? c=30; c) max = a>b ? a>c?a:c:b>c?b:c d) return (a>b)?(a:b)



Q8. Which of the following are unary operators in C?



1.  !
2.  sizeof
3.  ~
4.  && 


Options
a) 1, 2 b) 1, 3 c) 2, 4 d) 1, 2, 3



Q9. How many times the program will print "Datacode" ?


    int main()
{
    printf("IndiaBIX");
    main();
    return 0;
}
  


Options:
a) Infinite times b) 32767 times c) 65535 times d) Till stack overflows



Q10. The operator used to get value at address stored in a pointer variable is:


Options
a) * b) & c) && d) ||