logo

CuriousTab

CuriousTab

Discussion


Home C Programming Control Instructions Comments

  • Question
  • What will be the output of the program?
    #include<stdio.h>
    int main()
    {
        int x = 3;
        float y = 3.0;
        if(x == y)
            printf("x and y are equal");
        else
            printf("x and y are not equal");
        return 0;
    }
    


  • Options
  • A. x and y are equal
  • B. x and y are not equal
  • C. Unpredictable
  • D. No output

  • Correct Answer
  • x and y are equal 

    Explanation
    Step 1: int x = 3; here variable x is an integer type and initialized to '3'.
    Step 2: float y = 3.0; here variable y is an float type and initialized to '3.0'
    Step 3: if(x == y) here we are comparing if(3 == 3.0) hence this condition is satisfied.
    Hence it prints "x and y are equal".

    Control Instructions problems


    Search Results


    • 1. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int a=0, b=1, c=3;
          *((a)? &b : &a) = a? b : c;
          printf("%d, %d, %d\n", a, b, c);
          return 0;
      }
      

    • Options
    • A. 0, 1, 3
    • B. 1, 2, 3
    • C. 3, 1, 3
    • D. 1, 3, 1
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int k, num = 30;
          k = (num < 10)? 100 : 200;
          printf("%d\n", num);
          return 0;
      }
      

    • Options
    • A. 200
    • B. 30
    • C. 100
    • D. 500
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i = 1;
          switch(i)
          {
              printf("Hello\n");
              case 1:
                  printf("Hi\n");
                  break;
              case 2:
                  printf("\nBye\n");
                  break;
          }
          return 0;
      }
      

    • Options
    • A. Hello
      Hi
    • B. Hello
      Bye
    • C. Hi
    • D. Bye
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i = 5;
          while(i-- >= 0)
              printf("%d,", i);
          i = 5;
          printf("\n");
          while(i-- >= 0)
              printf("%i,", i);
          while(i-- >= 0)
              printf("%d,", i);
          return 0;
      }
      

    • Options
    • A. 4, 3, 2, 1, 0, -1
      4, 3, 2, 1, 0, -1
    • B. 5, 4, 3, 2, 1, 0
      5, 4, 3, 2, 1, 0
    • C. Error
    • D. 5, 4, 3, 2, 1, 0
      5, 4, 3, 2, 1, 0
      5, 4, 3, 2, 1, 0
    • Discuss
    • 5. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i=0;
          for(; i<=5; i++);
              printf("%d", i);
          return 0;
      }
      

    • Options
    • A. 0, 1, 2, 3, 4, 5
    • B. 5
    • C. 1, 2, 3, 4
    • D. 6
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i=4;
          switch(i)
          {
              default:
                 printf("This is default\n");
              case 1:
                 printf("This is case 1\n");
                 break;
              case 2:
                 printf("This is case 2\n");
                 break;
              case 3:
                 printf("This is case 3\n");
          }
          return 0;
      }
      

    • Options
    • A. This is default
      This is case 1
    • B. This is case 3
      This is default
    • C. This is case 1
      This is case 3
    • D. This is default
    • Discuss
    • 7. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int a = 500, b = 100, c;
          if(!a >= 400)
              b = 300;
          c = 200;
          printf("b = %d c = %d\n", b, c);
          return 0;
      }
      

    • Options
    • A. b = 300 c = 200
    • B. b = 100 c = garbage
    • C. b = 300 c = garbage
    • D. b = 100 c = 200
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int a = 300, b, c;
          if(a >= 400)
              b = 300;
          c = 200;
          printf("%d, %d, %d\n", a, b, c);
          return 0;
      }
      

    • Options
    • A. 300, 300, 200
    • B. Garbage, 300, 200
    • C. 300, Garbage, 200
    • D. 300, 300, Garbage
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          char str[]="C-program";
          int a = 5;
          printf(a >10?"Ps\n":"%s\n", str);
          return 0;
      }
      

    • Options
    • A. C-program
    • B. Ps
    • C. Error
    • D. None of above
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          char j=1;
          while(j < 5)
          {
              printf("%d, ", j);
              j = j+1;
          }
          printf("\n");
          return 0;
      }
      

    • Options
    • A. 1 2 3 ... 127
    • B. 1 2 3 ... 255
    • C. 1 2 3 ... 127 128 0 1 2 3 ... infinite times
    • D. 1, 2, 3, 4
    • Discuss


    Comments

    There are no comments.

Enter a new Comment