Sunday, 15 December 2013

C Program to Multiply given Number by 4 using Bitwise Operators

#include < stdio.h>
 
void main()
{
    long number, tempnum;
 
    printf("Enter an integer \n");
    scanf("%ld", &number);
    tempnum = number;
    /*  left shift by two bits */
    number = number << 2;
    printf("%ld x 4 = %ld\n", tempnum, number);
}

Output

 Enter an integer
 450 
 450  x  4  =  1800 

For More Details Please Visit Ictjobs.info

No comments: