C program to multiply given number by 4 using bitwise operators

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/* c program to multiply given number by 4 using bit-wise operators */

#include  <stdio.h>

void main()
{
long number, tempnum;

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

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

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

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

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program to accept a decimal number and conert it binary and count the number of 1′s in the binary number
  2. C program to reverse a given integer number and check whether it is a palindrome. Output the given numbers with suitable message
  3. C program to check whether a given integer number is positive or negative
  4. C program to check whether a given number is prime or not and output the given number with suitable message
  5. C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results

Leave a Comment

Previous post:

Next post: