Advertisement
valve2

right * left bit in a int explained

Jan 23rd, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. // this prog mult's the rightmost and leftmost
  2.  
  3. #include <stdio.h>
  4. // 12409 will be used for testing
  5. int num = 12409, l, r, ans ;
  6. int main() {
  7. // for the rightmost we will div by 10,000 ( for finding the rightmost we always divide
  8.     r = 12409 / 10000;
  9.         printf("right most = %d\n", r);
  10.         // since we have 1 ten thousand in 12409 the rightmost will be 1
  11.         l = 12409 % 100;
  12.         printf("leftmost = %d\n", l);
  13.  
  14.         // now we gotta mult them
  15.         ans = l * r;
  16.         printf("--------------------------\n");
  17.         printf("LSB mult by MSB = %d", ans);
  18.  
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement