Test 1 Answers

  1. What would be the value of i and k?
    main()
    {
         int i,j=5,k;
         i=2*j/2;
         k=2*(j/2);
    }
    ANS: 5 4
  2. What is the output of the following program?
    main()
    {
         int i=-1;
         printf(“i=%d,-i=%d”,i,-i);
    }
    ANS: i=-1 -i=1
  3. What is the output of the following program?
    main()
    {
         int i=10,j=40;
         if((j-i)%10)
              printf(“True”);
         else
              printf(“False”);
    }
    ANS: False
  4. What is the output of the following program?
    main()
    {
         char ch[]={‘e’,’n’,’d’,’\0’,’p’};
         printf(“%s”,ch);
    }
    ANS: end
  5. What is the output of the following program?
    main()
    {
    int i;
    for(i=1;i<5;i++);
    printf(“Hello”);
    }
    ANS: Hello
  6. What is the output of the following program?
    main()
    {
    int x,y=2,z,a;
    x=(y*=2)+(z=a=y);
    printf(“%d”,x);
    }
    ANS: 8
  7. What are the values of x,y,z after executing the following statements?
    int x=6,y=8,z;
    y=x++;
    z=++x;
    ANS: 8 6 8
  8. What is the output of the following program?
    main()
    {
    printf("%d",printf("Hello"));
    }
    ANS: Hello5
  9. What is the output of the following program?
    main()
    {
    char x=-256;
    printf(“%d”,x);
    }
    ANS: 0
  10. What is the output of the following program?
    main()
    {
    int i=4,j=20;
    if(i=5||j>50)
    printf(“Hello”);
    else
    printf(“Hi”);
    }
    ANS: Hello

No comments:

Post a Comment

Total Pageviews