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;
}
Discussion:
70 comments Page 2 of 7.
Jayesh said:
8 years ago
Thanks, nice explanation @Amey.
Maheswari said:
8 years ago
Yes, you can assigned integer value in char data type.
For example :
char i=21;
printf("%c",i); //it will not print anything and no error;
printf("%d",i);//it will print the value of I;
For example :
char i=21;
printf("%c",i); //it will not print anything and no error;
printf("%d",i);//it will print the value of I;
Dinesh said:
8 years ago
Can we assign an integer value in char data type?
Komal said:
8 years ago
Very nice, Thank you all.
Merlin said:
8 years ago
Good Explanation, thanks @Amey.
Hamilton said:
8 years ago
Thanks for all your explanation.
Shravan said:
9 years ago
@Sai.
Very good explanation. Thank you.
Very good explanation. Thank you.
Vasundhara said:
9 years ago
Thanks, easy explanations @Amey.
Rohit Singh said:
9 years ago
Thanks, @Sai & @Thirumalai.
Jitendra vaishnav said:
9 years ago
@Mukunda Saini.
OR operation doesn't means sum its logical or operation.
Where 1 OR 1 is 1. So there will be no carry on next position.
OR operation doesn't means sum its logical or operation.
Where 1 OR 1 is 1. So there will be no carry on next position.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers