c - P R O G R A M I N G - Sajha Mobile
SAJHA MOBILE
c - P R O G R A M I N G
Posts 2 · Viewed 7840 · Go to Last Post
comingsoon
· Snapshot 0
Like · Likedby · 0
Write a function that receives an integer, b, that represents a number of bytes. If 1 ≤ b ≤ 8, the function will return the largest positive value that an unsigned int of b bytes can represent. If b is not in the appropriate range, the function should return -1. The function declaration is
long largest(int);
Assume that this function will be executed on a 64-bit operating system. You can use the pow() function which returns a double with the value b^e when called with
pow(b, e).

Can somebody help?
helpjava11
· Snapshot 157
Like · Liked by · 0
Basically you need to understand the logic for this problem.
1 byte = 8 bit  ( Are sure you dont mean 8 bits, bit and byte are different)
You can find the largest possible integer value possible with any bit with this forlula: (2^n-1)
In your case  Total integer = 2^64 = 18446744073709551616
That means you can represent 0 to 18446744073709551615 with 8 bytes.

#include<math.h> main() { double b = 64; b = pow(2,b); }
This is not a complete code, try for yourself. If you still have doubt contact me

Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 16 · Viewed 8572 · Likes 3
· Posts 8 · Viewed 5226 · Likes 3
· Posts 1 · Viewed 2537 · Likes 3
· Posts 1 · Viewed 2753 · Likes 3
· Posts 1 · Viewed 2391
· Posts 1 · Viewed 2391
· Posts 1 · Viewed 2550
· Posts 1 · Viewed 2657
· Posts 1 · Viewed 2459
· Posts 11 · Viewed 12358



Travel Partners
Travel House Nepal