Users Online
· Guests Online: 149
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
42 C Program to Multiply given Number by 4 using Bitwise Operators
This C Program multiplies given number by 4 using bitwise operators. The bitwise operators are or, and, xor, not, left shift, right shift. Program uses left shift operator for this.
Here is source code of the C program to multiply given number by 4 using bitwise operators. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to multiply given number by 4 using bitwise operators
*/
#include
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);
}
$ cc pgm62.c
$ a.out
Enter an integer
450
450 x 4 = 1800
Here is source code of the C program to multiply given number by 4 using bitwise operators. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C program to multiply given number by 4 using bitwise operators
*/
#include
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);
}
$ cc pgm62.c
$ a.out
Enter an integer
450
450 x 4 = 1800
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.