pitchacool
BAN USERA mutex is a lockable object that is designed to signal when critical sections of code need exclusive access. Of course, it prevents other threads with the same protection from executing concurrently and access the same memory locations. If miused on readable/sharable sections, it causes thread holdups and response delays for other threads.
- pitchacool August 27, 2013TCP is a reliable protocol and UDP needs additional layer of fault tolerance. TCP requires dedicated connection while UDP doesn't.
- pitchacool August 27, 2013A simple solution is quoted below from umich.edu site
#include <iostream.h>
void binary(int);
void main(void) {
int number;
cout << "Please enter a positive integer: ";
cin >> number;
if (number < 0)
cout << "That is not a positive integer.\n";
else {
cout << number << " converted to binary is: ";
binary(number);
cout << endl;
}
}
void binary(int number) {
int remainder;
if(number <= 1) {
cout << number;
return;
}
remainder = number%2;
binary(number >> 1);
cout << remainder;
}
--------------------------------------------------------------------------------
Sample Run
Please enter a positive integer value: 24
24 converted to binary is: 11000
This program prompts the user for a positive integer. The function binary divides the integer by 2 (using the bitshift operation) until the number becomes 1, at which point it outputs 1 and steps back thru the function calls outputting the remainder from previous divisions. This program has been tested and works for all integers within C++ limits.
static variable is never on stack, like globals, they will be in the data segment of the program and they exist for initialization prior to program main starts.
- pitchacool August 27, 2013