Test 2 Answers

  1. What is the output of following program?
    #include<stdio.h>
    double i;
    int main()
    {
    (int)(float)(char) i;
    printf("%d", sizeof((int)(float)(char)i));
    }
    Ans: 4
  2. What is the output of following program?
    #include<stdio.h>
    #define X a##b
    int main()
    {
    int a=2,b=3,ab=5;
    printf("%d", a+b+X);
    }
    Ans: 10
  3. What is the output of following program?
    #include<stdio.h>
    #define square(x) x*x
    int main()
    {
    printf("%d", square(2+3));
    }
    Ans: 11
  4. What is the output of following program?
    #include<stdio.h>
    static int i=5;
    int main(){
    int i=2,j,k;
    j=i++;
    k=++i;
    printf("%d,%d,%d",i,j,k);
    }
    Ans: 4,2,4
  5. What is the output of following program?
    #include<stdio.h>
    int main()
    {
    int k=1;
    printf("%d == 1 is" "%s\n", k, k==1?"True":"False");
    }
    Ans: 1 == 1 is True
  6. What is the output of following program?
    #include<stdio.h>
    int main(){
    int i;
    printf("%d\n", scanf("%d", &i));
    }
    Ans: 1
  7. What is the output of following program?
    #include<stdio.h>
    int main()
    {
    printf(6-2+"RISE_KRISHNA_SAI");
    }
    Ans: _KRISHNA_SAI
  8. What is the output of following program?
    #include<stdio.h>
    #include<string.h>
    int main()
    {
    char clg1[5]="rpra",clg2[5]="rgan";
    printf("%d",strcmp(clg1,clg2));
    }
    Ans: None
  9. What is the output of following program?
    #include<stdio.h>
    int main()
    {
    char name=255;
    printf("%d",name);
    }
    Ans: -1
  10. What is the output of following program?
    #include<stdio.h>
    int main()
    {
    int i=1;
    for(;i<10;i++);
    printf("%d",--i);
    }
    Ans: 9