Primary Why isn't sizeof for a struct equal to the sum of sizeof of each member? This is because of padding added to satisfy alignment constraints. Data structure alignment impacts both performance and correctness of programs. Here's an example using typical settings for an x86 processor (all used 32 and 64 bit modes): struct X { short s; /* 2 bytes */ /* 2 padding bytes */ int i;...
Primary Why is one loop so much slower than two loops? Suppose a1, b1, c1, and d1 point to heap memory and code has the following loop. const int n=100000; for(int j=0;j<n;j++){ a1[j] += b1[j]; c1[j] += d1[j]; } This loop is executed 10,000 times via another outer for loop. To speed...
Primary Why is processing a sorted array faster than an unsorted array? Here is a piece of Visual C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster. #include <algorithm> #include <ctime> #include <iostream> int main() { // Generate data const unsigned arraySize = 32768; int data[arraySize]...
Primary What is the difference between #include <filename> and #include “filename”? The difference is in the location where the preprocessor searches for the included file. For #include "filename" the preprocessor searches in the same directory as the file containing the directive. This method is normally used to include programmer-defined header files. For #include <filename> the preprocessor...
Primary What are the differences between a pointer variable and a reference variable? * A pointer can be re-assigned: int x = 5; int y = 6; int *p; p = &x; p = &y; *p = 10; assert(x == 5); assert(y == 10); A reference cannot, and must be assigned at initialization: int x = 5; int y = 6; int &r = x; * A pointer has...
Primary What is the name of the "-->" operator? Here's an example: #include <stdio.h> int main() { int x = 10; while( x --> 0 ) // x goes to 0 { printf("%d ", x); } } Answer --> is not an operator. It is in fact two separate operators, -- and >. The conditional's code decrements x,...
Swift Introduction to Swift - Swift Programming Language Swift is a new programming language for iOS, OS X, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Development on Swift was begun in July 2010 by Chris Lattner, with the eventual collaboration of many other programmers at...
Swift Download Swift for Windows Swift is a general-purpose, multi-paradigm, compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc. Update - 22 SEPTEMBER 2020 From 22 September 2020, the Swift project introduced new downloadable Swift toolchain images for Windows. These images contain development components needed to build...
Wiki Git Cheat Sheet (Git Commands) Git is a version control system that is widely used for software development and other version control tasks. It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Git was initially designed and developed in 2005 by Linux kernel...
Wiki Google Advertising vs Facebook Advertising, which one better for Mobile App Campaigns? Mobile app installs campaigns are geared specifically toward getting more people to download your app. When more people download your app, you could improve your app store ranking, which in turn can result in even more people downloading your app. Here we going to discuss about two advertising platform Google...
iOS Alcatraz - The package manager for Xcode Alcatraz is an open-source package manager for Xcode 7+. It lets you discover and install plugins, templates and theme without the need for manually cloning or copying files. It installs itself as a part of Xcode and it feels like home. How to install Alcatraz? Installing Alcatraz is very...
Primary Quiz - Loops (for, while, do while, break, continue and goto) in C Programming This quiz is based on this Loops in C tutorial including introduction to for loop, while loop, do while loop, break, continue statement, and goto. So, To get better score on quiz, read the tutorial first. Poll Maker...
Wiki These Google Chrome tips, tricks and hacks will change the way you use the chrome. Compose a new email directly from Chrome's address bar * Go to Settings * In Search section click on the Manage Search Engines button * Create a new row called Email Compose, * Use the keyword email , * Use this query in the third box mailto:?subject=%s * Just as you type email...
Primary Turbo C++ IDE Shortcuts S.No. Shortcuts keys Action 1 F1 For Help 2. F2 Save 3. F3 Open 4. F4 Go to cursor 5. F5 Zoom 6. F6 Next 7. F7 Trace into 8. F8 Step over 9. F9 Make 10. F10 Menu 11. Alt+X Quit 12. Alt+Bksp Undo 13. Shift+...
Primary Quiz - Decision Control, Expression and Operators in C This quiz is based on the and Expression & Operators Precedence and The Decision Control Structure tutorial. So, To get better score on quiz, read the tutorial first. Poll Maker...