C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - Find Output of Program (Q.No. 7)
7.
What will be the output of the program?
#include<stdio.h>

int main()
{
    char c=48;
    int i, mask=01;
    for(i=1; i<=5; i++)
    {
        printf("%c", c|mask);
        mask = mask<<1;
    }
    return 0;
}
12400
12480
12500
12556
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
70 comments Page 7 of 7.

Pramod Soni said:   1 decade ago
Thank you very much Amey.

Vraj shah said:   1 decade ago
Thanks amey :).

Chinna said:   2 decades ago
To increment five times in i and multiple by c and i and mask.

Bhavesh said:   1 decade ago
"c|mask" what does it mean?

Ajit Yadav said:   1 decade ago
For those having problem in 5th loop.
C = 48 = 110000.
Mask= 16 = 010000.
Perform or operation and you will get 110000 i.e. 48.
And 48 in ascii is '0'.

Mun said:   1 decade ago
Left shift << is Multiply by power of 2.
So therefore ,12480 consecutively 5 times !!

Ravi said:   1 decade ago
Thanks sai.

Rohit said:   1 decade ago
@Sai. Thank you very nuch.

Lavanya duddu said:   1 decade ago
<< means Leftshoft operations
lets take number 2 (0010) if you do left shift operation it becomes 0100(4)
so short cut for << operation is just multiply by two.

Poobal said:   1 decade ago
Please any one can explan this program clearly ?


Post your comments here:

Your comments will be displayed after verification.