Bitwise operators usage in c

C Language

C Programs

/* Write a c program to multifly given number by 4 *
* using bitwise operators */

#include

void main()
{
long number, tempnum;

printf(“Enter an integern”);
scanf(“%ld”,&number);
tempnum = number;
number = number << 2; /*left shift by two bits*/

printf(“%ld x 4 = %ldn”, tempnum,number);
}

/*——————————
Output
Enter an integer
15
15 x 4 = 60

RUN2
Enter an integer
262
262 x 4 = 1048
———————————*/

Share

No related posts.

Subscribe / Share

sriramraj tagged this post with: Bitwise operators, C language, C programs Read 162 articles by

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Like us in Google +