Home / C Programming / Control Structures :: Discussion

Discussion :: Control Structures

  1. 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);

    }

  2. A.

     20

    B.

     24

    C.

     25

    D.

     30

    E.

     None of these

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Condition if(c[a]%2 == 1) forces only odd numbers to add in the sum.


Be The First To Comment