C Programming Language Do , While Quizzes


  • 3. Output of following program?

    int main()
        {
            while ()
                printf("In while loop ");
            printf("After loop\n");
        }
    





  • 2. What is the output of the following program fragment?

    int main()
        {
            do
                printf("In while loop ");
            while (0);
                printf("After loop\n");
        }





  • 3. Output of following program?

    int main()
        {
            int i = 0;
            do {
                i++;
                printf("In while loop\n");
            } while (i < 3);
        }
    





  • 4. What must the test be so that the following fragment prints out the integers 5 through and including 15?

    int main()
        {
            int i = 0;
            do {
                i++;
                printf("in while loop\n");
            } while (i < 3);
        }





  • 5. What must the change be so that the following fragment prints out the even integers 0 2 4 6 8 10?

    int main()
        {
            int i = 0;
            while (i < 3)
                i++;
            printf("In while loop\n");
        }
    





  • 6. What is the output of this C code?

    void main()
        {
            int i = 2;
            do
            {
                printf("Hi");
            } while (i < 2)
        }





  • 7. What is the output of this C code?

    void main()
        {
            int i = 0;
            while (++i)
            {
                printf("H");
            }
        }
    





  • 8. Which of the following will print the value 2 for the below program ?

    void main()
        {
            int i = 0;
            do
            {
                printf("Hello");
            } while (i != 0);
        }
    





  • 9. What is the output of this code?

    for ( int count = 0;  count < 9;   )
      System.out.print( count + " " );
      count++ ;
    System.out.println( );
    





  • 10. What is the output of this C code?

    int j;
    for ( j = 0;  j < 5;   )
    {
      System.out.print( j + " " );
      j++ ;
    }
      
    System.out.println( );