Function to find the given number is a power of 2 or not?
Answer Posted / hassan noureddine
int isPowrOf2 (unsigned int number)
{
float x;
if (number <= 0) return (0);
x = log(number) / log(2);
return ( (int) ( ((int)x*log(2))/log(number)));
}
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
What is graph in c?
The purpose of this exercise is to benchmark file writing and reading speed. This exercise is divided into two parts. a). Write a file character by character such that the total file size becomes approximately >10K. After writing close the file handler, open a new stream and read the file character by character. Record both times. Execute this exercise at least 4 times b). Create a buffer capable of storing 100 characters. Now after generating the characters, first store them in the buffer. Once the buffer is filled up, store all the elements in the file. Repeat the process until the total file size becomes approximately >10K.While reading read a while line, store it in buffer and once buffer gets filled up, display the whole buffer. Repeat the exercise at least 4 times with different size of buffer (50, 100, 150 …). Records the times. c). Do an analysis of the differences in times and submit it in class.
What is a static function in c?
What are external variables in c?
what value is returned to operating system after program execution?
Write a program to print numbers from 1 to 100 without using loop in c?
What is difference between constant pointer and constant variable?
What is #error and use of it?
Explain what are global variables and explain how do you declare them?
How many keywords are there in c?
How do you search data in a data file using random access method?
How can I handle floating-point exceptions gracefully?
Explain what header files do I need in order to define the standard library functions I use?
Why is c faster?
what is the format specifier for printing a pointer value?