Home / C Programming / Control Structures :: control structures

C Programming :: Control Structures

  1. What will be the output of given program?

    #include<stdio.h>

    void main()

    {

    int a=1;

    if("%d=hello", a);

    }

  2. A.

     complier error

    B.

     no error no output

    C.

     0

    D.

     1

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of given program?

    #include<stdio.h>

    void main()

    {

    int a=3;

    for(;a;printf("%d ", a--);

    }

  4. A.

     no output

    B.

     3 2 1 0

    C.

     3 2 1

    D.

     infinity loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of given program?

    #include<stdio.h>

    void main()

    {

    int i=1, j=-1;

    if((printf("%d", i)) < (printf("%d", j)))

    printf("%d", i);

    else

    printf("%d", j);

    }

  6. A.

     1 -1 1

    B.

     1 -1 -1

    C.

     1

    D.

     -1

    E.

     complier error

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the following piece of code?

    for(i = 0; i<10; i++);

    printf("%d", i);

  8. A.

     10

    B.

     0123456789

    C.

     Syntax error

    D.

     0

    E.

     Infinite loop

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the following code?

    #include

    void main()

    {

    int s=0;

    while(s++<10)

    {

    if(s<4 && s<9)

    continue;

    printf("%dt", s);

    }

    }

  10. A.

     1 2 3 4 5 6 7 8 9

    B.

     1 2 3 10

    C.

     4 5 6 7 8 9 10

    D.

     4 5 6 7 8 9

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which command is used to skip the rest of a loop and carry on from the top of the loop again?

  12. A.

     break

    B.

     resume

    C.

     continue

    D.

     skip

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  • What is the output of the following program?

    #include<stdio.h>

    int c[10] = {1,2,3,4,5,6,7,8,9,10};

    main()

    {

    int a, b=0;

    for(a=0;a<10;++a)

    if(c[a]%2 == 1)

    b+=c[a];

    printf("%d", b);

    }

  • A.

     20

    B.

     24

    C.

     25

    D.

     30

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  • What is the output of the following statements?

    for(i=10; i++; i<15)

    printf("%d ", i);

  • A.

     10 11 12 13 14

    B.

     10 11 12 13 14 15

    C.

     9 10 11 12 13

    D.

     Infinite loop

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  • The type of the controlling expression of a switch statement cannot be of the type ........

  • A.

     int

    B.

     char

    C.

     short

    D.

     float

    E.

     long

    View Answer

    Workspace

    Discuss Discuss in Forum


  • What's wrong in the following statement, provided k is a variable of type int?
    for(k = 2, k <=12, k++)

  • A.

     The increment should always be ++k .

    B.

     The variable must always be the letter i when using a for loop.

    C.

     There should be a semicolon at the end of the statement.

    D.

     The variable k can’t be initialized.

    E.

     The commas should be semicolons.

    View Answer

    Workspace

    Discuss Discuss in Forum