Wikipedia:Reference desk/Archives/Computing/2014 March 8

= March 8 =

LOOPS IN C
this is a piece of code and do is without any braces.so is it correct? 101.222.236.208 (talk) 14:56, 8 March 2014 (UTC) thanks everybody.it wasnt a homework actually it was an exercise from book and it was not what i had learned about syntax of do while loops so i thought of getting second opinion.


 * I've added some formatting for you to make it easier to read. Dismas |(talk) 15:22, 8 March 2014 (UTC)


 * Someone else might correct me but I believe you have to have the braces. I'm also not sure why you have so many conditions.  If I were doing it, I would say something like:

thanks everybody.it wasn't a homework problem,it was an exercise from book and it was a conflict from what i had learned about do while loops regarding syntax.the actual values where 5,4,3 instead of 7,6,5.and code compiled and output was 9 so i thought of getting a second opinion for better clarification.
 * Try that. Dismas |(talk) 15:28, 8 March 2014 (UTC)
 * I think you're probably missing the point.  The code is nothing a programmer would ever use, but I think it is syntactically valid -- it should compile.  This looks to me like a homework problem where the goal is to figure out what value is printed for i at the end.  Because it looks like a homework problem, I'm reluctant to give the answer. Looie496 (talk) 15:53, 8 March 2014 (UTC)
 * Not really a good piece of homework, either. Just having an automatic formatter indent the code should make the structure clear. --Stephan Schulz (talk) 16:04, 8 March 2014 (UTC)
 * The challenge is not to understand the structure, it's to figure out the effects of the ++ operators and how they interact with the loop control. (By the way, I verified that the code does compile in gcc without any errors or warnings.) Looie496 (talk) 16:18, 8 March 2014 (UTC)


 * I'd agree with what Stephan Schulz said. Being able to write 'puzzle' code is not the mark of a good programmer.  The mark of a good programmer is the ability to write readable, maintainable code that accomplishes a given task.  If one of my developers turned out crappy code like that, I would make them rewrite it, and if they continued to write crappy code, I'd let them go.  A Quest For Knowledge (talk) 16:21, 8 March 2014 (UTC)


 * As I said, I think it's probably a problem from a programming class, and I think it's a pretty good problem -- it's an excellent test of understanding of how loops and increment operators work. (The answer, by the way, is 11. Can you work out why?) Looie496 (talk) 16:37, 8 March 2014 (UTC)


 * The braces are optional, but you've put a semi-colon after the while statements. This will work


 * The semi-colon between the while and printf leads to an empty statement so that your code loops 7 times doing nothing for the first while loop, and the next two while loops do nothing, as the conditional is false, and then it does the printf once. stdout is line buffered by default in C, so you won't see anything until your code exits.
 * Additionally, there is the


 * and the


 * construct, the latter doesn't have a end-marker, but it's at the end of the next statement, or block. CS Miller (talk) 16:40, 8 March 2014 (UTC)


 * As others have said, this is probably an exercise to figure out what the code does. It helps understand the language, and programmers often have to read and modify somebody elses crappy code so there is value in being able to decipher it even if you don't write it. Your code does something else than the original code which is indeed crappy, but in a real situation it could have been part of a program you have to modify without changing the final value of i (hint: i++ increments i after evaluating i). Going back to the question of whether the original code has valid syntax, it's certainly allowed to have no braces in a do loop but is it allowed to omit the first semicolon in ? gcc allows it but does the standard? And most compilers would probably disallow the quotation characters used by the poster in “%d”. The normal is "%d" but I don't know whether the standard deals with such issues. PrimeHunter (talk) 16:59, 8 March 2014 (UTC)
 * is followed by a statement, simple or compound. The first  is inside the loop made by the   and the second  . If you put in your semicolon, then the   and first   form the loop with an empty statement, followed by two additional loops.  --Stephan Schulz (talk) 17:49, 8 March 2014 (UTC)
 * Right, I was confused by the odd code and C's use of  in two different loop structures. It prints the same value with or without a semicolon there, so if this is an exercise to test understanding of loops then it might have been better if it gave different results. PrimeHunter (talk) 18:38, 8 March 2014 (UTC)

Linux
I have been offered a rather unique opportunity in the technology world, but one stipulation is I must familiarize myself with Linux. However I am not in a position to purchase the OS or a computer to run it, so I was wondering if there is any sort of online simulation that exists, or if anyone knows of any free or cheap programs I might enroll myself in. Any other informative literature is greatly appreciated! Thanks, 71.2.144.134 (talk) 16:46, 8 March 2014 (UTC)
 * The good thing about Linux is, that for by far the most distributions, you don't need to purchase it, it's available for free of charge. And if you don't want to purchase a computer either, you can use an existing PC for it, but you do need a separate hard disk, or at least a separate partition. J I P  &#124; Talk 16:52, 8 March 2014 (UTC)
 * Most distributions will have a CD or DVD based installer available for you to download, either via your web-browser, or bit-torrent (preferred), you only need the first CD/DVD of the set, it can download everything else that is needed. Also, Linux will run on very old hardware, the minimum specification for the Debian distribution is a 80486 CPU, they were first manufactured in 1989. You can also buy a Raspberry Pi for around $50, it will need a USB keyboard, USB mouse, a HDMI or DVI monitor/TV, and a USB power supply (as used for charging most mobile phones). The Pi is a bit slow, but will do for learning. CS Miller (talk) 17:04, 8 March 2014 (UTC)
 * If you have access to a computer you can install software on, you could run various flavours of Linux under VirtualBox. Runs a little slower than it would if run nativly, but not terrible much so. WegianWarrior (talk) 17:13, 8 March 2014 (UTC)
 * My WP:OR is that the slowdown of virtualization is fairly negligible these days, if you are not running an X server. I run scientific simulations on VM that are very computationally expensive, with just a few % decrease in speed compared to running on the native OS. It's highly optimized FORTRAN code though, so that might allow it to slow down less on VM, compared to other tasks. SemanticMantis (talk) 17:01, 9 March 2014 (UTC)


 * You can use a bootable USB stick with e.g. Ubuntu, and get a full-fledged, if slow, Linux system. If you only need to learn the shell, you can get a private virtual server for roughly the equivalent of 2 or 3 beers in a pub per month, and use PuTTY or any other ssh implementation to log in. --Stephan Schulz (talk) 20:26, 8 March 2014 (UTC)


 * I don't think it's available quite yet (should be by sometime in summer), but the Linux foundation is organizing a free MOOC that covers introductory Linux, see details here . Depending on your timeline, that looks like a good bet. With a virtual machine as advised above, you can learn a lot just by playing around, with no worry about breaking things. If your VM gets messed up, you can easily revert to an earlier image, or just delete the whole thing and start a fresh one. SemanticMantis (talk) 16:57, 9 March 2014 (UTC)


 * I am in a similar position now: a "unique opportunity" which I myself created, the need to use Linux which I chose after rejecting some other options but my overall position is different. I do have powerful hardware, years of experience in Fortran, Pascal, C#, some C++ and C and MS Visual Fox database language. I began using and learning Linux about 6 weeks ago. And I do it mostly on weekends. This is what I can say from my rather short experience so far. Linux is enormous. I was totally shocked when I found it out. I think the number of commands is roughly an order of magnitude larger than for instance in C#. It is all a result of open source and voluntary contribution of many people. I do have Win 7 machine (Rack mount R5400), Oracle Virtual Box where I installed Ubuntu. It was not easy. First I tried to do it in Windows Server 2008 which I have on the second hard disk and all installation failed. In Win 7 it all went smoothly. I think the OP is looking for a situation which does not exist in real life: sort of an emulation Linux at a website he can use with his TV? It will unlikely be a good learning experience. There are Linux courses but they are not cheap. I would say they start at 2 grand or much more. --AboutFace 22 (talk) 19:28, 9 March 2014 (UTC)


 * Seconding 's suggestion above. If you have Windows now, follow these directions to create a bootable USB stick with Ubuntu on it. It won't erase Windows -- it'll run entirely from the usb stick so you can just reboot and unplug it to stop using it. Most Linux distributions have pretty intuitive GUIs. Ubuntu and Linux Mint, for example, aren't a very substantial learning curve for your average Windows or Mac user. The first challenge for me when I first started using it was understanding the file system, which is very different from that of Windows. Once you know how to use "packages" to download/install software to do what you need to do, you'll have to start learning the command line as things come up. It's not practical to just set out to learn all the commands, since, depending on what you'll be using it for, you'll probably only use a few regularly beyond the standard directory interaction commands. Linux has a huge community that are generally enthusiastic and even evangelistic, so there are many resources to find help. Ubuntu has its own active forums. If a google doesn't do the trick, post there and someone will tell you how to do something. --&mdash;  Rhododendrites talk  |  19:52, 9 March 2014 (UTC)


 * Point of order: OP, can you tell us what you need to know about Linux? For instance getting "familiar" with the Bash shell and basic operation of a Linux system is fairly straightforward with a little practice (and learning Ubuntu GUI is even easier), but being "familiar" with the Linux kernel is a lofty goal which I have never aspired to! SemanticMantis (talk) 21:22, 9 March 2014 (UTC)

Throttling / capping
Presumably WP utilizes server throttling, but does it also apply per-user "capping"? If so, is it possible to determine if an individual user (this one, for example) has been capped? The reason I'm asking is that for the last couple of days, my WP pages load very slowly (if at all). I am wondering if it's just me, or is WP having problems? I've done all the usual things to assure that there is no problem on my end, and the rest of the Internet is just fine on this computer. IP=71.20.250.51 (talk) 17:55, 8 March 2014 (UTC)


 * I haven't noticed a recent slowdown. Try using Wikipedia at off hours (4 AM ?), and see if that helps. StuRat (talk) 18:37, 9 March 2014 (UTC)


 * Same thing is happening to me. First I thought it's my provider who recently started limiting speed in the evening (could be the snowbirds' fault) but WP is the only site I have severe loading problems. BTW, even Netflix streaming still works fine with the capped speed.TMCk (talk) 20:02, 9 March 2014 (UTC)

Manage Add-ons that run without permission in MS Windows7 OS
I would like to know what Microsoft add-ons that are installed in Windows7, under manage add-ons that run without permission that collects my browsing history and everything else about me. What can i removed from this list without causing a problem in OS? I do not use internet explorer, i have Windows7, i unable most windows programs. I don't like that MS collects information about me and uses it for their benefit without my permission(s) to do so. Please show in a lists which to delete of MS collecting my data. ty — Preceding unsigned comment added by Sagr8 (talk • contribs) 18:50, 8 March 2014 (UTC)


 * Windows 7 does not ship with any Internet Explorer add-ons that collect your browsing history or other personal information. I think the Bing Bar may do so, but only if you install it. What's your reason for believing that Microsoft is collecting information about you? -- BenRG (talk) 20:49, 8 March 2014 (UTC)


 * You might want to read Windows 7 Privacy Statement, and "Online privacy and security: frequently asked questions" (linked from page). 71.20.250.51 (talk) 21:00, 8 March 2014 (UTC)
 * ...And: Learn about privacy settings for... (various MS add-ons) Added:21:06, 8 March 2014 (UTC) — Preceding unsigned comment added by 71.20.250.51 (talk)


 * There are websites under a generic name(s) "Lean windows," "lean operating system," etc. They all recommend to get rid of some windows components. Try that/ --AboutFace 22 (talk) 19:52, 12 March 2014 (UTC)

Netflix "Important Reminder"
The past couple of days, every time I go to Netflix, I get an "Important Reminder" prompting me to agree to their terms of service and privacy policy. I agree every time, but if I come to the site an hour later, I have to do it again. Is anyone else having this problem, and is there a way to stop it? --Lazar Taxon (talk) 23:58, 8 March 2014 (UTC)


 * I just checked my Netflix account and didn't get the reminder. Dismas |(talk) 00:11, 9 March 2014 (UTC)


 * Not doing it about 8 hours ago on the Canadian version. CambridgeBayWeather (talk) 01:03, 9 March 2014 (UTC)

Well, I should rephrase - the question of whether other people are having the same problem is kind of immaterial to me. But does anyone know what might be causing it, and how to get rid of it? I'm using OS X 10.9, and it happens in all browsers. (It's even happened to me twice since posting here.) Edit: It also happens on the computer in the next room running Windows. --Lazar Taxon (talk) 02:05, 9 March 2014 (UTC)


 * Such problems are often caused by caching or cookie problems; the site can't save the fact that you've agreed to the TOS. You can sometimes solve them by logging out and back in again, clearing your cache of the page, or clearing your cookies for the page.  The process to do these varies by browser.  Netflix also has telephone based tech support for subscribers that I have found to be better than average. gnfnrf (talk) 04:42, 9 March 2014 (UTC)


 * gnfnrf is probably right about the cookies, but instead of deleting Netflix's cookie, you might need to enable cookies for that site, if you have set browser for no cookies (or a security/privacy app that monitors and/or deletes cookies). Most likely, their cookie is how Netflix records that it already gave you the reminder.  — 71.20.250.51 (talk) 05:00, 9 March 2014 (UTC)


 * But would that explain it happening in all browsers (all of them set to accept cookies) on multiple machines? --Lazar Taxon (talk) 06:14, 9 March 2014 (UTC)


 * The only remaining possibility in my view is that there's something wrong with your account. That is, there is a server-side issue in this case, rather than a client-side issue. Have you tried contacting Netflix? It could also be geographic or network-related, but you could rule that out too by logging into your account from a computer at work or at the library.&mdash;Best Dog Ever (talk) 08:03, 9 March 2014 (UTC)


 * I doubt it's cookies. I have Firefox set to wipe cookies on quitting (though it seems not to do so consistently for some sites), so I have to log in at Netflix every day; and I haven't seen such behavior. —Tamfang (talk) 08:10, 9 March 2014 (UTC)