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 4 of 7.

Zhongshunchao said:   7 years ago
0011 0000 == 48 ---0
0011 0001 == 49 ---1 48|0001.
0011 0010 == 50 ---2 48|0010.
0011 0100 == 52 ---4 48|0100.
0011 1000 == 56 ---8 48|1000.
0011 0000 == 48 ---0 48|0000.

Zhongshunchao said:   7 years ago
0011 0000 == 48 ---0.
0011 0001 == 49 ---1.
0011 0010 == 50 ---2.
0011 0100 == 52 ---4.
0011 1000 == 56 ---8.
0011 0000 == 48 ---0.

Neha said:   7 years ago
Thanks @Amey.

Ruhee said:   7 years ago
Thanks @Jayadeep.

Padma said:   7 years ago
Thank You @Sai.

Dhivya said:   7 years ago
How to find ascii value manually?

Please explain.

Kirubhakaran said:   1 decade ago
It is nothing but shifting the binary values to left !! In case if u have a binary number 11001101, after you left shit this binary number by 1 digit, you will have 10011010.. that is, the first digit is removed and a he remaining elements are written and a zero is appended at last...

Adi said:   1 decade ago
Razia, its not printing mask.

Its printing 49 as 49-48=1
then 50-48=2
then 52-48=4 and
then 48-48=0 on it prints 12480.

Pawan mishra said:   1 decade ago
Thanks sir realy understoodable answer. Thank you so much.

Jhansi said:   1 decade ago
Thanks alot sai.


Post your comments here:

Your comments will be displayed after verification.