For people that are familiar with coding and stuff, this is a fun game! I will use a for loop and some numbers, try and figure out the output . Also it can be in any language you want, and the only person that can make his own output puzzel is the one who guesses the persons puzzle thats before him. For example if I make one, and A gets it wrong but B gets it right, B can then make his own output puzzle. Anyways lets start! for(x=0; x<=10; x--) printf("%d" , x); Its C by the way. Anyways guess what number x is at last. p.s its pretty easy.
It depends on x. You haven't specified the datatype of x, whether it is double or int, whether its signed or unsigned....
The value of x goes on reducing until it becomes the lowest value possible (depends on the datatype and compiler). On the next decrement the MSB of the number changes and the numbers switches to the largest possible value. Which will be surely greater than 10. Hence that will be the printed value. The maximum and minimum values for different datatypes can be found in the follwing page. http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.5.html
Ah ok, value of x will be lowest value possible, if x is integer and program is made in C then x will -2147483647.
if x is unsigned, then the lowest possible value is 0 and it will be the output. If the variable is signed char, then the answer is -127. In some compilers the size of int is 4 and in some its 2. If the datatype is of 2 byte size, then the answer is -32767(This is true for short int also). If the size is 4 byte then the answer is -2147483647(this is true for long int also).
Lol we have smart people on the forum! YAY The X's starting value is 0. It will keep going until X is less than or equal to 10. So it will go once more since X does equal to 10 so it actually goes 11. So in the end the number is 11. Good guess though designcode
I don't get you. Initially x is 0. Since 0 <= 10, it prints '0' Then x is DECREMENTED not incremented. So the value of x becomes -1. since -1 <= 10, '-1' gets printed Then x is again decremented. This process goes on until x reaches the minimum possible value for that variable (depend on the datatype of x). Lets assume that x is signed integer. Then value of x decreases upto -32768. Since this is also less than 10, the value of x is further decremented. and the value of x becomes +32767, which is greater than 10. Hence the loop gets broken.
I checked your code with the following program #include<stdio.h> #include<conio.h> void main(){ int x; clrscr(); for(x=0; x<=10; x--){ printf("%d" , x); } printf("%d", x); getch(); } Code (markup): And the output was what I predicted (+32767).
oh im sorry then YOU WIN. I will check later at home with codewarriors program. Anyways anyone else wanna continue?
I doubt anyone can guess that, lol. But I'll post it anyway. <?php class dumb { function ae($i) { return $i . str_repeat(chr(61), strlen('bs')); } function wha() { return (10 * 6) + 4; } function d() { return sprintf('de%s%sde', 'c', 'o'); } function fi($i) { list($x, $y) = array_map('c' . 'h' . 'r', explode(chr(124), $i)); return $x . $y; } } $l = array(7 . implode(chr(124), array(2, 9)) . 7, 8 . implode(chr(124), array(1, 9)) . 0, 6 . implode(chr(124), array(5, 9)) . 8, 1 . implode(chr(124), array(19, 9)) . 8); $b = 'hrns' . dumb::wha(); foreach ($l AS $k => $g) { $l[$k] = dumb::fi($g); } $f = array_map(array('dumb', 'ae'), array_map(strrev('verrts'), $l)); $c = range(0, sizeof($l) - 1); $s = strtr($b . '_', 'rhsn', 'abes') . dumb::d(); foreach ($c AS $n) { $rl = $s($f[$n]); switch (true) { case ($n === 0): $rl = strtoupper($rl); break; case ($n % 3 == 0): eval($s('ZWNobyAnbCc7')); } echo $rl; } ?> PHP:
I doubt it will run without throwing errs, can you put a boolean as the comparer in a switch? "switch (true)" ?
I too have the same doubt. The expression of the switch statement requires a variable or conditon, that can evaluate to a constant value, right? Can we use a constant value there?
Yep, this is possible. Here some examples that may seem odd, but work. (You can set the conditions in the cases as well.) $foo = true; switch ($foo) { case true: echo 'true'; break; case false: echo 'false'; } switch (true) { case (1 === 1): // Or any other condition that is TRUE echo 'true'; break; case ($foo == false): echo 'false'; } PHP:
But wouldn't the switch statement becomes pointless in that case? You know the switch condition and the work to performed for that condition. So why don't we use it directly?
Look at the second example. It's basically like a if/elseif. It's just another way to do it, not always necessarily the best...